Overriding plugin configuration via commandline

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Overriding plugin configuration via commandline

ml-22
Hi,

When I specify a property for a plugins goal on the command line, like:

   mvn kilt:reformat -Dformat="<key> = <value>\n"

this works as expected, as long as this property (in this case "format")
isn't set in the pom for that plugin. Otherwise the configuration in the
pom.xml apparently takes precedence before the parameter that is given on
the command line. I would expect it the other way around.

This is the definition of the above mentioned property in the ReformatMojo:

  @Parameter(property="format", defaultValue = "<key> = <value>\\n",
required = true)
  private String format;

Do I need to configure something differently in the Mojo to be able to
override settings that are already set in the pom.xml?


(If someone is curios: the above mentioned plugin is this one:
https://github.com/hupfdule/kilt/tree/master/kilt-maven-plugin)


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Overriding plugin configuration via commandline

Bernd Eckenfels
yes user properties for plugins only work for default values. If you want to  allow overwrite, you need to define the default as a property and overwrite it with system property or in a profile and the use the property in the plugin config.

Be aware that it is a good thing if a Pom without external config can be used for reproducebable builds, I would therefore use it only for limited cases.

Gruss
Bernd


--
http://bernd.eckenfels.net

________________________________
Von: [hidden email]
Gesendet: Freitag, November 29, 2019 10:00 PM
An: [hidden email]
Betreff: Overriding plugin configuration via commandline

Hi,

When I specify a property for a plugins goal on the command line, like:

mvn kilt:reformat -Dformat="<key> = <value>\n"

this works as expected, as long as this property (in this case "format")
isn't set in the pom for that plugin. Otherwise the configuration in the
pom.xml apparently takes precedence before the parameter that is given on
the command line. I would expect it the other way around.

This is the definition of the above mentioned property in the ReformatMojo:

@Parameter(property="format", defaultValue = "<key> = <value>\\n",
required = true)
private String format;

Do I need to configure something differently in the Mojo to be able to
override settings that are already set in the pom.xml?


(If someone is curios: the above mentioned plugin is this one:
https://github.com/hupfdule/kilt/tree/master/kilt-maven-plugin)


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]