【问题标题】:Upload multiple aar 's to Nexus using jenkins - gradle release使用 jenkins 将多个 aar 上传到 Nexus - gradle release
【发布时间】:2017-07-25 12:59:15
【问题描述】:

我需要上传从多模块项目生成的多个 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();
    }
  } 
}

发布构建.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 这成功将我所有的快照上传到 Nexus。

gradle release - 它成功发布但没有上传任何东西到 Nexus 但是构建成功。

你能帮我解决我缺少的问题吗?

【问题讨论】:

    标签: gradle android-gradle-plugin aar gradle-plugin gradle-release-plugin


    【解决方案1】:

    你不能在安卓项目中使用普通的maven 插件。你必须使用这个:https://github.com/dcendents/android-maven-gradle-plugin

    您的 uploadAllArchives 任务也是多余的,只需从根项目运行 gradle uploadArchives

    【讨论】:

      【解决方案2】:

      你可以通过添加得到它

      afterReleaseBuild.dependsOn project.getSubprojects().collect({it.getTasks().getByName("uploadArchives")})
      

      如果你想为所有子项目上传它,那会这样做,但如果你的根项目也产生一个工件,你必须用 getAllprojects() 替换 getSubprojects()

      【讨论】:

      猜你喜欢
      • 2016-05-24
      • 2015-04-22
      • 2018-09-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多