You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Matt Nelson (Jira)" <ji...@apache.org> on 2024/01/16 17:24:00 UTC
[jira] [Commented] (MCOMPILER-97) META-INF/services/javax.annotation.processing.Processor copied before compilation and causes error
[ https://issues.apache.org/jira/browse/MCOMPILER-97?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17807362#comment-17807362 ]
Matt Nelson commented on MCOMPILER-97:
--------------------------------------
{quote}
one could list the annotation processors or processor path explicitly, but this results in a POM that is hard to develop and maintain (in the sense that one would have to construct this enumeration and keep it up-to-date) in contrast with a POM that does not list them explicitly and instead relies on the default discovery behavior
{quote}
It appears that this is the direction that javac is heading towards.
https://inside.java/2023/10/23/quality-heads-up/
> META-INF/services/javax.annotation.processing.Processor copied before compilation and causes error
> --------------------------------------------------------------------------------------------------
>
> Key: MCOMPILER-97
> URL: https://issues.apache.org/jira/browse/MCOMPILER-97
> Project: Maven Compiler Plugin
> Issue Type: Bug
> Affects Versions: 2.0.2
> Environment: Ubuntu 8.10, JDK 6.
> Reporter: Jesse N. Glick
> Priority: Major
> Attachments: MCOMPILER-97-workaround.zip, maven-6647998-test.zip
>
>
> It is tricky to compile a Maven module which defines a (269-compliant) annotation processor. If you write the code for the processor in src/main/java and register it in src/main/resources, META-INF/services/javax.annotation.processing.Processor is copied to target/classes first, and then javac is run. But javac is given target/classes in -classpath, so it tries to load the processor, which of course has not been compiled yet - a chicken-and-egg problem.
> The most straightforward workaround is to specify <compilerArgument>-proc:none</compilerArgument> in your POM. This will only work, however, if the module does not use any annotation processors defined in dependencies. If it does, there may be some other trick involving -processorpath and Maven variable substitution to insert the dependency classpath.
> Switching the order of resources:resources and compiler:compile would help - at least a clean build would work - though it could still cause problems in incremental builds. Better would be for the compiler plugin to pass -processorpath based on the dependency classpath (i.e. -classpath minus target/classes) when using -source 1.6 or higher.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)