Issue
I have a JDK11 Maven parent project and a POM file in C:\workspaces\parent-project\pom.xml This is the POM file I run with "mvn clean install". I also have other children projects. Inside this parent POM I need to access the directory in which it resides.
I have this plugin in the parent POM:
<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<version>2.16.0</version>
<configuration>
<configFile>${project.basedir}/java-formatter-configuration.xml</configFile>
<overrideConfigCompilerVersion>true</overrideConfigCompilerVersion>
<compilerSource>11</compilerSource>
<compilerCompliance>11</compilerCompliance>
<compilerTargetPlatform>11</compilerTargetPlatform>
<lineEnding>CRLF</lineEnding>
<encoding>UTF-8</encoding>
</configuration>
<executions>
<execution>
<goals>
<goal>format</goal>
</goals>
</execution>
</executions>
</plugin>
Unfortunately ${project.basedir} returns the directory of the children projects as they build 1-by-1. Tomcat has the variable ${CATALINA_BASE} that points at the installation directory of Tomcat. Is there the same I can do in the parent POM so that I can represent the directory in which the parent POM resides? Meaning, do you know which Maven variable I can use to access the directory C:\workspaces\parent-project? I had to make a copy of this formatter XML in every single project. I just want to have one formatter XML in the parent folder. Thank you
Solution
I would suggest to read the documentation of the formatter-maven-plugin because it support a configuration setup where you don't need file system access out of the box.
Answered By - khmarbaise
Answer Checked By - David Marino (JavaFixing Volunteer)