I wanted pass maven command line parameter to POM.xml so that i can use those value for some other purpose in building purpose.
Passing an Argument to MavenMaven will use the value (2.5) passed as an argument to replace the COMMON_VERSION_CMD property set in our pom. xml. This is not limited to the package command — we can pass arguments together with any Maven command, such as install, test, or build.
To provide System Properties to the tests from command line, you just need to configure maven surefire plugin and use -D{systemproperty}={propertyvalue} parameter in commandline. Run Single Test with Maven : $ mvn test -Dtest=MessageUtilTest#msg_add_test -Dmy_message="Hello, Developer!"
Yes you can use Maven Profiles to manage this. Obviously you can tweak this approach to suit your needs however works best.
mvn install "-Dsomeproperty=propety value"
In pom.xml:
<properties> <someproperty> ${someproperty} </someproperty> </properties>
Referred from this question
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