我正在开发版本的android库。以下是定义的构建类型:
buildTypes {
debug{
versionNameSuffix "-DEBUG"
}
dev{
versionNameSuffix "-RC"
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
//define code for appending the versionname suffix for the plugin
}
// need the versionNameSuffix from the runtime buildvariant selected
version "1.1.0-${versionNameSuffix}"
group 'com.mylib.android-libs'
根据在运行时选择的构建变体,maven存储库文件夹和文件中的工件名称需要附加上面定义的相应versionNameSuffix,从而在发布时在存储库中生成以下结构。
mylibrary
|_ 1.1.0
|__mylibrary-1.1.0-sources.jar
|__mylibrary-1.1.0.aar
|__mylibrary-1.1.0.pom
|_ 1.1.0-DEBUG
|__mylibrary-1.1.0-DEBUG-sources.jar
|__mylibrary-1.1.0-DEBUG.aar
|__mylibrary-1.1.0-DEBUG.pom
|_ 1.1.0-RC
|__mylibrary-1.1.0-RC-sources.jar
|__mylibrary-1.1.0-RC.aar
|__mylibrary-1.1.0-RC.pom
这是神器块:
artifactory {
contextUrl = "${artifactoryUrl}"
publish {
repository {
repoKey = 'maven-local'
username = "${user}"
password = "${password}"
maven = true
}
defaults {
publishConfigs('archives', 'published')
properties = ['build.status': "$it.project.status".toString()]
publishPom = true //Publish generated POM files to Artifactory (true by default)
publishIvy = false //Publish generated Ivy descriptor files to Artifactory (true by default)
}
}
resolve {
repository {
repoKey = 'repo'
username = "${user}"
password = "${password}"
maven = true
}
}
}
答案 0 :(得分:0)
您的修改完全改变了您的问题!这是我的新答案:
首先,您需要将publishNonDefault true
添加到android
部分:
android {
...
publishNonDefault true
...
}
然后使用addFilter修改uploadArchives部分以从项目上传多个存档。 See section 31.6.4.1 here
uploadArchives {
repositories {
mavenDeployer {
repository(url: "file://${System.properties['user.home']}/.m2/repository")
// addfilter for multiple pom upload
addFilter('debug') { artifact, file ->
artifact.attributes.classifier.equals("debug")
}
addFilter('dev') { artifact, file ->
artifact.attributes.classifier.equals("dev")
}
addFilter('release') { artifact, file ->
artifact.attributes.classifier.equals("release")
}
pom('debug').version = project.version + "-DEBUG"
pom('dev').version = project.version + "-RC"
pom('release').version = project.version
}
}
}
运行uploadArchives导致:
├───1.1.0
│ mylibrary-1.1.0-release.aar
│ mylibrary-1.1.0-release.aar.md5
│ mylibrary-1.1.0-release.aar.sha1
│ mylibrary-1.1.0.pom
│ mylibrary-1.1.0.pom.md5
│ mylibrary-1.1.0.pom.sha1
│
├───1.1.0-DEBUG
│ mylibrary-1.1.0-DEBUG-debug.aar
│ mylibrary-1.1.0-DEBUG-debug.aar.md5
│ mylibrary-1.1.0-DEBUG-debug.aar.sha1
│ mylibrary-1.1.0-DEBUG.pom
│ mylibrary-1.1.0-DEBUG.pom.md5
│ mylibrary-1.1.0-DEBUG.pom.sha1
│
└───1.1.0-RC
mylibrary-1.1.0-RC-dev.aar
mylibrary-1.1.0-RC-dev.aar.md5
mylibrary-1.1.0-RC-dev.aar.sha1
mylibrary-1.1.0-RC.pom
mylibrary-1.1.0-RC.pom.md5
mylibrary-1.1.0-RC.pom.sha1
repository
可以是任何maven回购。我还没有使用Artifactory上传进行测试,但我知道artifactory应该从maven插件配置中获取配置。