${revision}
tag can be used in pom.xml as described here.
Having this directory structure:
fix
├── pom.xml
├── parent
│ └── pom.xml
└── example
└── pom.xml
pom.xml has:
<project>
<groupId>intellij</groupId>
<artifactId>fix</artifactId>
<version>${revision}</version>
<properties>
<project.parent.basedir>parent</project.parent.basedir>
</properties>
<packaging>pom</packaging>
<modules>
<module>parent</module>
<module>example</module>
</modules>
<modelVersion>4.0.0</modelVersion>
</project>
parent/pom.xml has:
<project>
<groupId>intellij</groupId>
<artifactId>parent</artifactId>
<properties>
<revision>1.0.0</revision>
</properties>
<parent>
<groupId>intellij</groupId>
<artifactId>fix</artifactId>
<version>${revision}</version>
</parent>
<packaging>pom</packaging>
<modelVersion>4.0.0</modelVersion>
</project>
And example/pom.xml :
<project>
<groupId>example</groupId>
<artifactId>example</artifactId>
<parent>
<groupId>intellij</groupId>
<artifactId>parent</artifactId>
<version>${revision}</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
</project>
IntelliJ reports:
Whereas mvn
on terminal parses it well and works.
This breaks a lot of stuff in IntelliJ.
I tried this with IntelliJ 2019.2
Just a hint. If you do a simply mvn clean
on command with the structure you will see this:
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] parent 1.0.0 ....................................... SUCCESS [ 0.146 s]
[INFO] example 1.0.0 ...................................... SUCCESS [ 0.003 s]
[INFO] fix ${revision} .................................... SUCCESS [ 0.002 s]
[INFO] ------------------------------------------------------------------------
and this shows there is something wrong here...cause the version property can not be resolved in the root pom....and this is the reason why IDEA IntelliJ tells you that there is something wrong....as you see the root project in the last line which is indicator there is an issue.
If you move the revision property correctly into the root project (fix) than you will see this:
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ example ---
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for fix 1.0.0:
[INFO]
[INFO] fix ................................................ SUCCESS [ 0.106 s]
[INFO] parent ............................................. SUCCESS [ 0.003 s]
[INFO] example ............................................ SUCCESS [ 0.002 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.255 s
[INFO] Finished at: 2020-01-28T20:56:22+01:00
[INFO] ------------------------------------------------------------------------
In this output you see the fix
at the first line which is correct.
I strongly recommend to change your structure correctly and do not use <relativePath>../parent/pom.xml</relativePath>
in your example
project which is an indicator your directory structure does not represent your real structure which you have created within your pom files.
This should result in a structure as given in the example project on github which I have create:
https://github.com/khmarbaise/so-question-1
Apart from that please add the flatten-maven-plugin
as described in the documentation to your project otherwise you will fail in cases you are using mvn clean install
or mvn clean deploy