我坚持将 artifactory 3.0.1 插件与 Gradle 集成。我正在使用 Android Studio 1.0,所以我猜我在使用 Gradle 2.0。任何有关使用 3.0.1 插件发布到 Artifact 的示例都会非常有帮助。
提前致谢
最佳答案
发布到 Artifactory 只是一个配置任务。您只需要配置com.jfrog.artifactory
和maven-publish
两个插件,然后运行artifactoryPublish
Gradle 的任务。但是...让我们通过代码来解释它,以便于复制粘贴:·)
在你的图书馆的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') } } }
然后,运行./gradlew artifactoryPublish
此外,如果您想在每次将标签推送到 GitHub 时上传 Artifact ,请将此代码添加到您的 .travis.yml
deploy: - provider: script script: ./gradlew artifactoryPublish skip_cleanup: true on: tags: true
如果在您将标签推送到 GitHub 时它没有为标签启动构建,请检查您是否正在 Travis 上构建 vX.X.X
标签:
# Build only master and "vX.X.X" tags to prevent flooding Travis machines branches: only: - master - /^v\d+\.\d+\.\d+$/
关于android - 将 Android aar 发布到 artifactory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27684789/