jfrog gradle 上传jar 包
时间: 2023-08-15 13:08:52 浏览: 220
上传文件jar包
您可以使用以下步骤将 Jar 包上传到 JFrog Artifactory:
1. 在 build.gradle 文件中添加以下代码,以配置 JFrog 插件:
```
buildscript {
repositories {
maven {
url "${artifactory_contextUrl}/plugins-release"
credentials {
username = "${artifactory_user}"
password = "${artifactory_password}"
}
name = "maven-username-plugins"
}
}
dependencies {
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:<latest-version>"
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:<latest-version>"
}
}
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'maven-publish'
artifactory {
contextUrl = "${artifactory_contextUrl}"
publish {
repository {
repoKey = '<your-repo-name>'
username = "${artifactory_user}"
password = "${artifactory_password}"
maven = true
}
defaults {
publications ('<your-publication-name>')
}
}
}
```
2. 在 gradle.properties 文件中添加以下代码,以配置 Artifactory 的用户名和密码:
```
artifactory_contextUrl=<your-artifactory-url>
artifactory_user=<your-artifactory-username>
artifactory_password=<your-artifactory-password>
```
3. 将 Jar 包添加到发布配置中,在 build.gradle 文件中添加以下代码:
```
publishing {
publications {
maven(MavenPublication) {
groupId = '<your-group-id>'
artifactId = '<your-artifact-id>'
version = '<your-version>'
artifact(file('<path-to-your-jar>'))
}
}
}
```
4. 运行以下命令将 Jar 包上传到 Artifactory:
```
./gradlew artifactoryPublish
```
这将把你的 Jar 包发布到 Artifactory 中的指定仓库中。
阅读全文