0

I have an idea to include an immutable (performs compile-time code generation of POJO) library into a legacy project. The main issue: the legacy project is used widely in other applications, so I do not want to have any new dependency at all. I found that question where it said it is possible to use tag annotationProcessorPaths for that purpose. I try to rework my config that way:

         <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.8.0</version>
                    <configuration>
                        <source>17</source>
                        <target>17</target>
                        <encoding>UTF-8</encoding>
                        <showWarnings>true</showWarnings>
                        <annotationProcessorPaths>
                            <annotationProcessorPath>
                                <groupId>org.immutables</groupId>
                                <artifactId>value</artifactId>
                                <version>2.9.2</version>
                            </annotationProcessorPath>
                        </annotationProcessorPaths>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>

it does not work. I get an error: Could not find artifact org.immutables:value:jar:unknown in case I add the library in dependency section - it works. As figure out later, looks like annotationProcessorPaths tag is just order of using annotation processors, but does not actually provide dependencies for them. Is it correct understanding? Is there any work around to use that annotation process without including it in dependency section at all?

sphinks
  • 3,048
  • 8
  • 39
  • 55
  • In fact it is not needed to declare the artifacts included in `annotationProcessorPaths` as dependencies. I have tried to reproduce this case starting from a clean maven project created using `archetype:generate` and everything works fine. I have compiled using mvn compile -X and I can see the jar being added to `processorpath`. By the way, according to [compiler plugin documentation](https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#annotationProcessorPaths) you should use `path` inside `annotationProcessorPaths`. – Jose Gisbert May 12 '23 at 19:17

0 Answers0