For years, we\'ve been running the maven-processor-plugin as a separate goal (using proc:none
on maven-compiler-plugin). We are finally upgrading from
You can use the maven-compiler-plugin
for annotation processing because the functionality exists in javac
. To do annotation processing and regular compilation in separate phases, you can do multiple executions of the plugin, one with annotation processing turned on, the other with it turned off. The configuration for that is as follows:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5</version>
<executions>
<execution>
<id>process-annotations</id>
<phase>generate-sources</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<compilerArgs>
<arg>-proc:only</arg>
<arg>-processor</arg>
<arg>MyAnnotationProcessor</arg>
</compilerArgs>
</configuration>
</execution>
<execution>
<id>default-compile</id> <!-- using an id of default-compile will override the default execution -->
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<compilerArgs>
<arg>-proc:none</arg>
</compilerArgs>
</configuration>
</execution>
</executions>
</plugin>