user3877467
user3877467

Reputation: 111

maven versions:set not updating parent pom

I've following parent pom file:

     <?xml version="1.0" encoding="UTF-8"?>
<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>com.xyz</groupId>
        <artifactId>abc</artifactId>
        <version>1.0.0.36</version>
        <packaging>pom</packaging>
        <name>Common Data Access Framework</name>
        <build>
        <pluginManagement>
    ...
    ...

Now when I run following command from the same folder where I have this parent pom file:

mvn versions:set -DnewVersion=9.9.9.9

It will update the version details in all child modules and pom file "except" it's own (the parent). This is really strange as I'm running it from the very same folder.

Upvotes: 2

Views: 1740

Answers (2)

Cosu
Cosu

Reputation: 588

I have hit a similar problem yesterday. The cause was that my parent pom.xml had leading whitespace before the xml tag. After removing it version:set worked as expected, setting the version across all poms,parent and children. I don't know if this was the solution in your case but I'm posting this to save another poor soul hours of stupid debugging.

Upvotes: 3

Gerold Broser
Gerold Broser

Reputation: 14762

Tried the following here with Maven 3.3.3's mvn version:set -DnewVersion=... in the root folder:

- root
  - sub-1
  - sub-2
  • If the subs are just childs (with <parent>root</parent>), just the root POM's <project>/<version> is updated. The subs <parent>/<version>s are not!
  • If the subs are childs and modules, the root POM's <project>/<version> and the subs <parent>/<version>s are updated.
  • If the subs are just modules only the root POM's <project>/<version> is updated as expected.

This is different to your result but it's no less strange because versions:set says:

Sets the current project's version and based on that change propagates that change onto any child modules as necessary.

The sub modules were childs at each of two topmost runs mentioned above.

UPDATE

The reason for the parent POM not updated can be that 9.9.9.9 is not a standard Maven version:

A project’s version number is used to group and order releases. Maven versions contain the following parts: major version, minor version, incremental version, and qualifier. In a version, these parts correspond to the following format:

<major version>.<minor version>.<incremental version>-<qualifier>

If you use a nonstandard versioning scheme, Maven release and version plug-in goals might not yield the expected results. Because basic string comparison is performed on nonstandard versions, version comparison calculates the order of versions incorrectly in some cases.

Upvotes: 1

Related Questions