mavenmaven-versions-plugin

versions-maven-plugin:update-property not updating pom.xml


Hi Meier I have used the following goal:

mvn versions:update-property
    -Dproperty="emom.web.dependency.shr.version"
    -Dincludes:org.safeway.com:emom-shr
    -DgenerateBackupPoms=false
    -DallowIncrementalVersios=true
    -DallowSnapshots=true
    clean package

My Job B pom.xml is:

<dependency>
  <groupId>com.safeway.app</groupId>
  <artifactId>emom-shr</artifactId>
  <version>${emom.web.dependency.shr.version}</version>
</dependency>

Under the properties it has the version hard-coded:

<emom.web.dependency.shr.version>19.6.5-SNAPSHOT</emom.web.dependency.shr.version>

My Job A pom.xml:

<groupId>com.safeway.app</groupId>
<artifactId>emom-shr</artifactId>
<version>20.1.0-SNAPSHOT</version>
<packaging>jar</packaging>

When I run the above goal, Maven is picking the latest version (i.e. 20.1.0) from Artifactory but when I check the pom.xml of Job B under properties it still says 19.6.5. I need a way to change the 19.6.5 or current version to latest version available. Am I doing something wrong? I'm not able to figure it out.


Solution

  • Here's an example of versions-maven-plugin:update-property working in practice. I've used the common Mockito library as an example that works for everyone as it's in Maven Central.

    Starting with this POM (noting the mockito-version property):

    <project xmlns="http://maven.apache.org/POM/4.0.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>abc</groupId>
        <artifactId>def</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    
        <properties>
            <mockito-version>2.22.0</mockito-version>
        </properties>
    
        <dependencies>
            <dependency>
                <groupId>org.mockito</groupId>
                <artifactId>mockito-core</artifactId>
                <version>${mockito-version}</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
    
    </project>
    

    The simplest way to upgrade it to the latest release version is this:

    mvn versions:update-property -Dproperty=mockito-version
    

    Replace mockito-version with emom.web.dependency.shr.version in your case.

    You can then start to use more of the goal options to adjust the options. For example, you might:

    To apply this to your scenario, I think you need to: