我需要上传从多模块项目生成的多个 aar。我的项目结构如下。
Project Root
|--Main app
|--Sub-Module1
|--Sub-Module2
|--Sub-Module3
每个子模块都会生成 aar 文件,我需要将所有 aars 的发布版本上传到 Nexus 但是我不希望将 apk 上传到 Nexus。我正在传递所有来自 jenkins 的 nexus url 和 cred。
这是我的根 build.gradle
release {
failOnCommitNeeded = false
failOnPublishNeeded = true
failOnSnapshotDependencies = true
failOnUnversionedFiles = false
failOnUpdateNeeded = true
revertOnFail = true
preCommitText = ''
preTagCommitMessage = '[Gradle Release Plugin] - pre tag commit: '
tagCommitMessage = '[Gradle Release Plugin] - creating tag: '
newVersionCommitMessage = '[Gradle Release Plugin] - new version commit: '
tagTemplate = '$version'
versionPropertyFile = './gradle.properties'
versionProperties = []
buildTasks = ['uploadAllArchives']
scmAdapters = [
net.researchgate.release.GitAdapter
]
git {
requireBranch = ''
}
}
task ("uploadAllArchives") {
doLast{
println 'uploadAllArchives'
subprojects.each { subProject->
if(!subProject.name.contains('app') && !rootProject)
it.uploadArchives.execute();
}
}
}
发布-build.gradle
apply plugin: 'maven'
uploadArchives {
repositories {
mavenDeployer {
repository(url: (project.hasProperty('repoUrl') ? repoUrl
: sonatypeRepo)) {
authentication(userName: sonatypeUsername, password:
sonatypePassword)
pom.groupId = sonatypeGroupID
pom.artifactId = project.name
pom.version = version
}
}
}
}
子模块 build.gradle:
apply from: '../publish-build.gradle'
gradle clean build uploadArchives
这成功地将我的所有快照 aars 上传到 Nexus。
gradle release
- 它成功发布但没有上传任何东西到 Nexus 但是构建成功。
你能帮我解决我所缺少的吗?