Hello.
I would like to get to single version numbers of whole artifact version, i.e.
I would like to parse ${pom.version} and store each number in different
property, e.g. ${version.major}, ${version.middle}, ${version.minor} or more
generally: ${pom.versions[0], ${pom.versions[1], etc.
Reason? I handle with version numbers in other parts of pom.xml but I do not
want to use whole ${pom.version} string but just parts - first two numbers
or version without -SNAPSHOT suffix or both. See pom.xml example for more
info:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>tests</groupId>
<artifactId>test-a</artifactId>
<packaging>war</packaging>
<version>1.2.3-SNAPSHOT</version>
<url>http://localhost/projects/${prj.url.relative}/</url> <!-- !!! -->
<!-- url would be: "http://localhost/projects/tests/test-a/1.2/" -->
<distributionManagement>
<site>
<id>website.localhost</id>
<url>scp://localhost/maven-sites/${prj.url.relative}/</url> <!--
!!! -->
<!-- url would be:
"scp://localhost/maven-sites/tests/test-a/1.2/" -->
</site>
</distributionManagement>
<properties>
<prj.url.relative>${pom.groupId}/${pom.artifactId}/${version.major
}.${version.middle}</prj.url.relative>
<prj.webapp.context>${pom.artifactId}/${version.major}/${
version.middle}</prj.webapp.context>
<!-- context would be "test-a/1/2" and could be for example used in
ear plugin -->
</properties>
</project>
Did someone already solve this situation? Is it possible to make some
properties hook to enhance set of properties after pom reading and before
starting of first goal execution of any lifecycle/phase?
Thanks for your advice.
Best regards,
Libor