Issue
I'm importing a shared "bill of materials" (bom) in my dependencyManagement, like this:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.mycompany</groupId>
<artifactId>common-bom</artifactId>
<version>1.2.3</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
That common-bom
defines versions, and then I just use whatever version it defines, like this:
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
That's all working great, except that I also have this
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths combine.children="append">
<annotationProcessorPath>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.20</version>
</annotationProcessorPath>
</annotationProcessorPaths>
</configuration>
</plugin>
So now I anyway need to specify a lombok version, not for the actual dependency, but for the annotation processor path. Is there a way I can somehow use the same value? Can it for example be stored as a property in the common-bom?
Solution
This is not possible because maven-compiler-plugin does not currently follow dependencyManagement
rules (MCOMPILER-391, go vote for it!).
The only thing you can do for now it seems is to declare a lombok.version
property in the parent pom, and use that in your annotationProcessorPath
declaration.
(note that Spring Boot already defines such a property for Lombok)
Answered By - Didier L
Answer Checked By - Marie Seifert (JavaFixing Admin)