Dev
Dev

Reputation: 51

Replacing placeholder name with value in pom.xml

i am working with multimodule project and i wanted to put placeholder for version in my pom.xml so that our team members can build their own war/jar by using command line, without hardcoding version in parent pom and child poms. Currently the problem is placeholder value is not updated in .m2 folder. please help me to resove this issue.

Upvotes: 0

Views: 1416

Answers (2)

Shivam Som
Shivam Som

Reputation: 141

In order to update the placeholder values inside the pom file, then it can be done by below two commands

 mvn versions:set -DnewVersion="2.1.1"
 mvn versions:commit

Once done, you can trigger the build using the usual commands mvn package or mvn install

Upvotes: 1

Vikash Madhow
Vikash Madhow

Reputation: 1344

You can put properties in the pom.xml of your top-level project as such:

<project>
  <!-- other stuff ... -->
  <properties>
    <downloadSources>true</downloadSources>
    <downloadJavadocs>true</downloadJavadocs>
    <jdo.version>3.0</jdo.version>
    <datanucleus.version>2.2.1</datanucleus.version>
  </properties>
  ...
</project>

Then in your module pom.xml you can use a variable reference that will be replaced with the actual value. For example:

<dependency>
  <groupId>org.datanucleus</groupId>
  <artifactId>datanucleus-core</artifactId>
  <version>${datanucleus.version}</version>
</dependency>

Upvotes: 0

Related Questions