我正在尝试将命令行中的参数传递给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参数未被解析。我也看到它没有抛出任何错误,它在上面的print语句中打印正常。只有在传递pom groupid时才会出现问题。不确定参数是否无法传递到pom属性中,或者是否有任何特殊语法与此
由于
答案 0 :(得分:0)
使用适当的语法为此做了一些小道后,我终于使用了以下语法。
pom(' artifact1')。groupId =' com.ngs.dcd' +'。' + project.getProperties()。环境