将Android AAR发布到工件 [英] Publish Android aar to artifactory
问题描述
我一直坚持将人工的3.0.1插件与Gradle集成在一起.我正在使用Android Studio 1.0,所以我猜我在Gradle 2.0上.使用3.0.1插件发布到工件的任何示例都将非常有帮助.
I'm stuck with integrating artifactory 3.0.1 plugin with Gradle. I'm using Android Studio 1.0 so I'm guessing that I'm on Gradle 2.0. Any examples on publishing to artifactory using the 3.0.1 plugin would be highly helpful.
预先感谢
推荐答案
发布到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+$/
这篇关于将Android AAR发布到工件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!