I have parent pom with modules defined like so :
parent pom.xml
<?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"
<modelVersion>4.0.0</modelVersion>
<groupId>parent</groupId>
<artifactId>parent</artifactId>
<version>1.0.2-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>../proj1</module>
<module>../proj2</module>
</modules>
</project>
Here are the child module pom files :
proj2 pom.xml
<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>
<parent>
<groupId>parent</groupId>
<artifactId>parent</artifactId>
<version>1.0.2-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
<groupId>proj2</groupId>
<artifactId>proj2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
</project>
proj1 pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmln: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>
<parent>
<groupId>parent</groupId>
<artifactId>parent</artifactId>
<version>1.0.2-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
<groupId>proj1</groupId>
<artifactId>proj1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
</project>
But when I use the versions plugin it just sets the parent version number and not its modules. Here is the command I am using :
versions:set -DnewVersion=1.0.2-SNAPSHOT
Here is the output :
[INFO] proj1 ...................................... SKIPPED
[INFO] proj2 ...................................... SKIPPED
[INFO] parent ......................................SUCCESS
The sub modules are being skipped. How can I enable the sub modules to be also updated and not just the parent?
Update : ive tried deleting the version tag from the child module so child module now is :
<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>
<parent>
<groupId>parent</groupId>
<artifactId>parent</artifactId>
<version>1.0.2-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
<groupId>proj2</groupId>
<artifactId>proj2</artifactId>
<packaging>war</packaging>
</project>
<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>
<parent>
<groupId>parent</groupId>
<artifactId>parent</artifactId>
<version>1.0.2-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
<groupId>proj1</groupId>
<artifactId>proj1</artifactId>
<packaging>war</packaging>
</project>
But version number is not being updated in child pom files.
Update : Here is how I think this process works, please feel free to suggest revisions :
Theoritically (I havent tested this) in a nested file structure Maven will update the individual version numbers for each child module when the goal : 'ons:set -DnewVersion=1.0.2-SNAPSHOT' is run.
However in a flat file structure it is not required to specify the version number in the child modules if the parent module has the same version. This is because the child version number if not set will use the parent version number. So to update all of the child modules of a parent module just update the version numer of the parent module, if all of the child modules do not have version number set then they will have same version number as parent module.