Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replace Maven properties in pom.xml via command line

I want to replace a Maven property in a pom.xml file with a command line call via some Maven plugin.

<properties>
    <my.property>ISO-8859-1</my.property>
<properties>

Do you know of a plugin which is able to do that?

The versions plugin takes very long since it checks whether some dependency is available. Besides that it doesn't work in my case.

like image 668
Harold L. Brown Avatar asked Oct 14 '15 16:10

Harold L. Brown


People also ask

How do I set system properties in POM xml?

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!"

How do I edit a pom xml file?

To open the POM Editor, click on a project's pom. xml file. If you've customized the editors for a pom. xml file, and the POM Editor is not the default editor, you may need to right-click on the file and choose "Open With... / Maven POM Editor".

How do I access property in POM xml?

In maven pom. xml , a property is accessed by using ${property_name} . You can define your custom properties in Maven.

How do I pass a parameter in Maven?

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.


1 Answers

All you need to do is add the following when running maven on the command line

-Dmy.property=propertyValue
like image 83
TK8 Avatar answered Sep 28 '22 12:09

TK8