I have multi-module project with a lot of dependencies on different modules versions. At the moment versions are hardcoded and one needs to change them manually. So I decided to put all of them to a properties file and get properties values from it during project build.
Here is how I try to do it:
root pom.xml
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>./version.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
file version.properties
module1.version=1.1
module2.version=1.8
module3.version=5.4
example of module pom.xml
<properties>
<module1.project.version>${module1.version}</module1.project.version>
</properties>
<parent>
<groupId>com.mymodule</groupId>
<artifactId>test</artifactId>
<version>${module1.version}</version>
<relativePath>../pom.xml</relativePath>
</parent>
Build fails with:
Failed to execute goal org.codehaus.mojo:build-helper-maven-plugin:1.7:parse-version (parse-versions) on project ccm-agent: Execution parse-versions of goal org.codehaus.mojo:build-helper-maven-plugin:1.7:parse-version failed. NullPointerException -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:build-helper-maven-plugin:1.7:parse-version (parse-versions) on project ccm-agent: Execution parse-versions of goal org.codehaus.mojo:build-helper-maven-plugin:1.7:parse-version failed.
How can I read some properties from a file and configure pom.xml in correct way?