Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing Maven pom.xml <properties> values physically

I'm building a deployment pipeline for a couple of projects that depend on each other. Each build produces a new release build with a unique version number, which is deployed to a Maven repository. The downstream projects in the pipeline are then triggered with that new version as a dependency and built in like manner.

What I need is to change a property value in the pom.xml (or all poms in a multi module project) before building the project. For example in the following code the "0.1.200" would be changed to "0.1.345" (or whatever the latest build number is). Using system properties is not an option, because the updated pom will be deployed in a Maven repository, so the change must be persistent.

<properties>
    <foo.version>0.1.200</foo.version>
</properties>

<dependencies>
    <dependency>
        <groupId>com.example</groupId>
        <artifactId>foo</artifactId>
        <version>${foo.version}</version>
    </dependency>
</dependencies>

Is there some Maven plugin for doing this with one command line instruction? Else I will need to write a short script (e.g in Ruby) which parses and changes all the pom.xml files in the project.

like image 627
Esko Luontola Avatar asked Mar 02 '13 13:03

Esko Luontola


1 Answers

Yes, there exists a maven-replacer-plugin which is capable of this.

But if you're using some CI tool (which apparently you are) you could as well just stick with a custom script for this purpose.

like image 98
Andrew Logvinov Avatar answered Sep 16 '22 16:09

Andrew Logvinov