I got my maven artefact version e.g. 1.2.3.4.5-SNAPSHOT
which contains my official version (The version number actually visible to the customer) e.g. 1.2.3.4
as substring. Because I don't want to maintain two separate properties, I am extracting the product version out of the artefact version:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.10</version>
<executions>
<execution>
<id>plannedversion</id>
<goals>
<goal>regex-property</goal>
</goals>
<phase>validate</phase>
<configuration>
<name>official.version</name>
<value>${project.version}</value>
<regex>^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)(-SNAPSHOT)?$</regex>
<replacement>$1.$2.$3.$4</replacement>
</configuration>
</execution>
</executions>
</plugin>
That works quite well. If I print the version via ANT:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo>******** Displaying value of property 'official.version' ********</echo>
<echo>${official.version}</echo>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
I get
[echo] ******** Displaying value of property 'official.version' ********
[echo] 1.2.3.4
But if I try to use this property in any other plugin than ant, it is not evaluated.
<plugin>
<groupId>com.my.custom-plugin</groupId>
<artifactId>releasenotes-maven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<id>releasenotes</id>
<goals>
<goal>releasenotes</goal>
</goals>
<phase>validate</phase>
<configuration>
<dataSources>
<jira>
<url>http://my-jira:8080/jira</url>
<jql>fixVersion = ${official.version}</jql>
</jira>
</dataSources>
</configuration>
</execution>
</executions>
</plugin>
This returns Invalid JQL: 'fixVersion = ${official.version}'
which shows that the maven property has not been replaced before running my release notes plugin.
The order above shows the actual plugin order within my pom.xml.
Why is the property correctly replaced when using ant, and why does this not work when using other plugins?