Jfrog Artifactory 上传和下载jar

Jfrog Artifactory 上传和下载jar ,第1张

目录
  • 1. 上传jar
    • 1.1 创建工程
    • 1.2 修改build.gradle
    • 1.3 发布
  • 2. 下载jar

1. 上传jar
  • 创建仓库

  • gradle工程中上传jar参考官方文档和GitHub样例

1.1 创建工程
  • 这里创建了一个新的gradle工程,只有一个util文件,用来后续测试使用

1.2 修改build.gradle
buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath(group: 'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '4.+')
    }
}
plugins {
    id 'java'
}

apply plugin: 'com.jfrog.artifactory'
apply plugin: 'maven-publish'

group 'org.example'
version '1.1-SNAPSHOT'

repositories {
    mavenCentral()
}

dependencies {
}

test {
    useJUnitPlatform()
}

task sourcesJar(type: Jar) {
    from sourceSets.main.allJava
    archiveClassifier = 'sources'
}

artifactory {
    contextUrl = 'http://127.0.0.1:8082/artifactory'
    publish {
        repository {
            repoKey = 'fisher-gradle-dev' // The Artifactory repository key to publish to
            username = "admin" // The publisher user name
            password = "AP31jMy61H78ScCYE2ki1jRDaoB" // The publisher password
        }
        defaults {
            // Reference to Gradle publications defined in the build script.
            // This is how we tell the Artifactory Plugin which artifacts should be
            // published to Artifactory.
            publications('mavenJava')
            publishArtifacts = true
            // Properties to be attached to the published artifacts.
            properties = ['qa.level': 'basic', 'dev.team' : 'core']
            // Publish generated POM files to Artifactory (true by default)
            publishPom = true
        }
    }
}

publishing {
    publications {
        mavenJava(MavenPublication) {
            from components.java
            // 同时上传源码
            artifact sourcesJar
        }
    }
}

1.3 发布
  • 在Terminal下,执行gradle artifactoryPublish命令


2. 下载jar
  • 这里新建了一个gradle项目,在项目中使用时,在build.gradle文件中添加下面代码
plugins {
    id 'org.springframework.boot' version '2.5.4'
    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
    id 'java'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
}

repositories {
    mavenCentral()
    maven {
        url "http://127.0.0.1:8082/artifactory/fisher-gradle-dev"
//        如果需要密码登录,添加下面代码
//        credentials {
//            username = "admin"
//            password = "password"
//        }
    }
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'

    implementation group: 'org.example', name: 'demo', version: '1.1-SNAPSHOT'

    compileOnly 'org.projectlombok:lombok'
    annotationProcessor 'org.projectlombok:lombok'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

tasks.named('test') {
    useJUnitPlatform()
}

  • 使用jar内的方法

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/883673.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-14
下一篇 2022-05-14

发表评论

登录后才能评论

评论列表(0条)

保存