Overriding plugin parameters via commandline

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

Overriding plugin parameters via commandline

Marco Herrn
Hi,

if I try to call the following maven goal:

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

the parameter `format` is correctly set to the given value for the `reformat` goal of the `kilt-maven-plugin`.

However, if I specify this parameter also in the pom.xml:

      <plugin>
        <groupId>de.poiu.kilt</groupId>
        <artifactId>kilt-maven-plugin</artifactId>
        <version>0.4.0-SNAPSHOT</version>
        <configuration>
          <format>&lt;key&gt;\t: &lt;value&gt;\n</format>
        </configuration>
      </plugin>

the value given in the pom.xml always takes precedence. The cmdline parameter is ignored in that case.

What do I have to do to be able to override the values in the configuration? Do I need to specify the parameter in the ReformatMojo of the kilt-maven-plugin differently? It is currently specified as:

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

Do I need to specify something differently to override a configation setting in the pom.xml via commandline flags?

In case you are curios, I am talking about that plugin: 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 parameters via commandline

Enrico Olivelli
Il ven 29 nov 2019, 23:15 Marco Herrn <[hidden email]> ha
scritto:

> Hi,
>
> if I try to call the following maven goal:
>
>   mvn kilt:reformat -Dformat="<key> = <value>\n"
>
> the parameter `format` is correctly set to the given value for the
> `reformat` goal of the `kilt-maven-plugin`.
>
> However, if I specify this parameter also in the pom.xml:
>
>       <plugin>
>         <groupId>de.poiu.kilt</groupId>
>         <artifactId>kilt-maven-plugin</artifactId>
>         <version>0.4.0-SNAPSHOT</version>
>         <configuration>
>           <format>&lt;key&gt;\t: &lt;value&gt;\n</format>
>         </configuration>
>       </plugin>
>
> the value given in the pom.xml always takes precedence. The cmdline
> parameter is ignored in that case.
>
> What do I have to do to be able to override the values in the
> configuration? Do I need to specify the parameter in the ReformatMojo of
> the kilt-maven-plugin differently? It is currently specified as:
>
>   @Parameter(property="format", defaultValue = "<key> = <value>\\n",
> required = true)
>   private String format;
>
> Do I need to specify something differently to override a configation
> setting in the pom.xml via commandline flags?
>
> In case you are curios, I am talking about that plugin:
> https://github.com/hupfdule/kilt/tree/master/kilt-maven-plugin






Hi,
This is expected, you have to declare your own property in the <properties>
section of your pom.xml with value equals to your 'default' value.
Then you configure the plugin to use your new properly
<format>${myformat}</format>

Cheers
Enrico

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