更新时间:2023-09-19 21:14:16
发布到Artifactory只是一个配置任务.您只需要配置两个插件 com.jfrog.artifactory
和 maven-publish
,然后运行 artifactoryPublish
Gradle的任务.但是...让我们通过代码来解释它,以简化复制粘贴:·)
Publishing to Artifactory is just a configuration task. You just need to configure two plugins, com.jfrog.artifactory
and maven-publish
, and run artifactoryPublish
Gradle's task. But... let's explain it by code, to ease copypasting :·)
在您图书馆的 build.gradle
:
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'maven-publish'
publishing {
publications {
aar(MavenPublication) {
groupId 'com.fewlaps.something' //put here your groupId
artifactId 'productname' //put here your artifactId
version '7.42.0' //put here your library version
// Tell maven to prepare the generated "*.aar" file for publishing
artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")
}
}
}
artifactory {
contextUrl = 'https://your-artifactory-host.com/artifactory'
publish {
repository {
repoKey = "libs-release-local"
username = "username"
password = "password"
}
defaults {
// Tell the Artifactory Plugin which artifacts should be published to Artifactory.
publications('aar')
}
}
}
然后运行 ./gradlewartifactoryPublish
此外,如果您希望每次将标签推送到GitHub时都上传工件,请将此代码添加到您的 .travis.yml
In addition, if you want to upload the artifact everytime you push a tag to GitHub, add this code to your .travis.yml
deploy:
- provider: script
script: ./gradlew artifactoryPublish
skip_cleanup: true
on:
tags: true
如果在将标签推送到GitHub时未启动该标签的构建,请检查您是否正在Travis上构建 vX.X.X
标签:
If it doesn't launch a build for the tag when you push a tag to GitHub, check that you're building vX.X.X
tags on Travis:
# Build only master and "vX.X.X" tags to prevent flooding Travis machines
branches:
only:
- master
- /^v\d+\.\d+\.\d+$/