I have a Maven plugin and it is configured in the POM file as
<build>
<plugins>
<plugin>
<groupId>com.example</groupId>
<artifactId>example-maven-plugin</artifactId>
<configuration>
<scriptsPath>scripts</scriptsPath>
</configuration>
</plugin>
</plugins>
</build>
Now I want to override that scriptsPath
from from command line so I run
mvn -X example-maven-plugin:goal -DscriptsPath=scripts1
I can see that value of the scriptsPath
is still scripts
and not scripts1
. Could the configuration parameter be overriden from the command line ?
Unfortunately, there is no general way to override maven plugin configuration by using properties. If the plugin documentation does not explicitly allow you to use a property to set the configuration value you can use following pattern:
<properties>
<scripts.path>scripts</scripts.path>
</properties>
<build>
<plugins>
<plugin>
<groupId>com.example</groupId>
<artifactId>example-maven-plugin</artifactId>
<configuration>
<scriptsPath>${scripts.path}</scriptsPath>
</configuration>
</plugin>
</plugins>
</build>
and then execute maven as
mvn -X example-maven-plugin:goal -Dscripts.path=scripts1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With