uploadArchives with mavenDeployer to multiple repos

时间:2014-04-20 12:53:31

标签: gradle

我有一个gradle项目,就像其他两个项目的公共库一样。

其他两个项目各自托管一个嵌入式maven存储库,我希望将公共项目部署到。

我试过这个:

uploadArchives {
    repositories {
        mavenDeployer {
            repositories {
                repository(url: '../../../project-web-service/repo')
                repository(url: '../../../project-app/repo')
            }
        }
    }
}

但这只是部署到第二个回购。

我已阅读Configuring multiple upload repositories in Gradle build,但它没有涵盖mavenDeployer,所以我现在有点卡住了。

2 个答案:

答案 0 :(得分:1)

您可以创建两个自己的任务(从Upload扩展),就像这样:

task uploadFirst(type: Upload) {
  uploadDescriptor = true
  repositories {
    mavenDeployer {
      repositories {
        repository(url: '../../../project-web-service/repo')
      }
    }
  }
}

task uploadSecond(type: Upload) {
  uploadDescriptor = true
  repositories {
    mavenDeployer {
      repositories {
        repository(url: '../../../project-app/repo')
      }
    }
  }
}

答案 1 :(得分:0)

我遇到了同样的问题,只是能够通过提供其他存储库名称来解决它,但是仍然保留了自己的mavenDeployer闭包。

例如:

uploadArchives {
    repositories {
        mavenDeployer {
            name = 'WebService'
            repository(url: '../../../project-web-service/repo')
        }
        mavenDeployer {
            name = 'App'
            repository(url: '../../../project-app/repo')
        }
    }
}