Can I override the 'group' property from the command-line?


(jbisotti) #1

I’ve tried “-Pgroup=bar.foo.com” & “-Pproject.group=bar.foo.com” but neither seems to work. My build.gradle looks similar to this:

… subprojects {

group = “com.foo.bar”

task printProps << {

println “group: $project.group”

}

… } …


(jbisotti) #2

I forgot to mention in my original post, but “com.foo.bar” is what always gets printed.


(René Groeschke) #3

Hi, unfortunately overriding of plugin properties like group via cmd line properties as you tried it above is not yet supported. As a workaround you can define a custom property like “cmdGroup” and reassign it to the group property. have a look at the following snippet:

apply plugin:'java'
  group = "com.foo.bar"
   //check if -P property is set on command line
 //& assign it to the group property
if(hasProperty('cmdGroup')){
 group = cmdGroup
}
  task printProps << {
  println "group: $project.group"
 }

now you can set your group via command line by calling “-PcmdGroup=bar.foo.com

regards,


(jbisotti) #4

Rene, that did the trick. Thanks for the information and the work-around.