【问题标题】:Command line parameters are not being read in the uploadArchives task (pom properties)uploadArchives 任务(pom 属性)中未读取命令行参数
【发布时间】:2016-10-26 13:49:48
【问题描述】:

我正在尝试将命令行中的参数传递到 uploadArchives 任务中,以将工件上传到 nexus。问题是 pom groupid 无法正确解析命令行参数。 我正在使用以下命令运行

gradle -Penvironment=dcdev4_106 -Pupload -PuserName=xxx -Ppassword=xxxx uploadArchives

uploadArchives {
repositories {
mavenDeployer {
configuration = configurations.archives
repository(url: "http://repo.xxx.net/nexus/content/repositories/maven-internal-snapshot/"){
      if (project.hasProperty('upload')) {
       authentication(userName: "${userName}", password: "${password}")
      }
    }
    addFilter('artifact1') {artifact, file ->
        artifact.name == 'artifact1'
    }
    addFilter('artifact2') {artifact, file ->
        artifact.name == 'artifact2'
    }

    println "**** Inside uploading archives for ${environment}"

    pom('artifact1').version = '1.0-SNAPSHOT'
    //pom('artifact1').artifactId = '1.0-SNAPSHOT'
    pom('artifact1').groupId = 'com.ngs.dcd.${environment}'

我在这行 pom('artifact1').groupId = 'com.ngs.dcd.${environment}' 收到错误,其中 $environment 参数未得到解析。我还看到它没有抛出任何错误,并且在上面的打印语句中打印良好。问题仅在传递 pom groupid 时出现。不确定参数是否不能传递到 pom 属性中,或者是否有任何特殊语法

谢谢

【问题讨论】:

    标签: gradle maven-plugin


    【解决方案1】:

    在为此使用适当的语法进行了一些尝试之后,我终于让它使用以下语法。

    pom('artifact1').groupId = 'com.ngs.dcd' + '.' +project.getProperties().environment

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-12-21
      • 1970-01-01
      • 1970-01-01
      • 2021-02-02
      • 1970-01-01
      • 2018-11-29
      • 2011-07-06
      • 2021-12-15
      相关资源
      最近更新 更多