I have a bunch of projects like:
project1
project2
project3
........
project111
Each project compiled in jar: project-1.1.1.1.jar, .... Does it possible in parent folder add pom.xml so I can define version 1 time for all projects?
I have a bunch of projects like:
project1
project2
project3
........
project111
Each project compiled in jar: project-1.1.1.1.jar, .... Does it possible in parent folder add pom.xml so I can define version 1 time for all projects?
If you omit <version/>
it inherits from the parent. However, the <parent/>
element must contain a <version/>
for the parent, so the version must occur in every single POM, but only once.
You can do this:
parent pom.xml:
<project>
...
<version>${my-project-version}</version>
...
<properties>
<my-project-version>1.1.1</my-project-version>
</properties>
</project>
child pom.xml:
<project>
...
<parent>
<relativePath>../parent/pom.xml</relativePath>
<version>${my-project-version}</version>
</parent>
...
</project>
At least, this works for me.
Using a property and referencing it works... unless you are using the release plugin to do releases in which case it removes "-SNAPSHOT" from the version and automatically replaces all instances with the real version number - which overwrites any replacement variables you've set. You may be better off just setting it in each POM and using the release plugin to tag, increment, and release your project.