http://maven.apache.org/pom.html#Properties says property "values are accessible anywhere within a POM".
Should this read "are accessible in most places within a POM"?
I can specify the version of a dependency no problem like so:
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
But what about the version of the project itself like so:
<project xmlns="http://maven.apache.org/POM/4.0.0" ...>
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>${myversion}</version>
<properties>
<myversion>8</myversion>
</properties>
<modules>
<module>alpha</module>
<module>beta</module>
</modules>
...
If I try this <version> will not take the value 8. Here I've defined ${myversion} in the pom but the same seems to be the case if I specify -Dmyversion=8 on the command line.
If one of the modules specifies its parent with a hardcoded version number like so:
<parent>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>8</version>
</parent>
When I try to build then when maven comes to look at the module's pom it will say it cannot find the given parent pom with version 8.
However if I hardcode version in the parent to 8 as well, rather than using ${myversion}, then everything works fine.
So it seems to me that property substitution does not happen for the /project/version tag of the parent pom.
Is this the case or is there some other explanation for what I seem to be seeing?
Regards,
/George