Is there way to get parent directory for ${basedir}
in my pom.xml? Currently I have
<earSourceDirectory>${basedir}/EAR/src/main/resources</earSourceDirectory>
but I need to access parent directory of basedir as my resources lies in different maven project.
How can I get the parent folder of ${basedir}
?
project. basedir : The directory that the current project resides in. This means this points to where your Maven projects resides on your system. It corresponds to the location of the pom.
It's a directory where the pom. xml is stored (in the root of the project).
A parent pom. xml file (or super POM) in Maven is used to structure the project in order to avoid redundancies and duplicate configurations by using an inheritance between different pom. xml files. If any dependency or properties are configured in both - parent and child - pom.
All Maven POMs inherit values from a parent POM. If a POM does not specify a direct parent using the parent element, that POM will inherit values from the Super POM. Project Inheritance shows the parent element of project-a which inherits the POM defined by the a-parent project. Project Inheritance.
${project.basedir}/../
However, access resources in a different module is something I try to avoid. I'd suggest using the unpack goal of the maven-dependency-plugin.
In the children:
<properties>
<main.basedir>${project.parent.basedir}</main.basedir>
</properties>
In the grandchildren:
<properties>
<main.basedir>${project.parent.parent.basedir}</main.basedir>
</properties>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With