apache / apache/maven-compiler-plugin
[MCOMPILER-97] META-INF/services/javax.annotation.processing.Processor copied before compilation and causes error
- Dominant language
- Java
- Stars
- 261
- Forks
- 191
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 8
Description
**[Jesse N. Glick](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=jglick)** opened **[MCOMPILER-97](https://issues.apache.org/jira/browse/MCOMPILER-97?redirect=false)** and commented
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 \-proc:none\ 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.
---
**Affects:** 2.0.2
**Attachments:**
- [maven-6647998-test.zip](https://issues.apache.org/jira/secure/attachment/12714883/maven-6647998-test.zip) (_7.64 kB_)
- [MCOMPILER-97-workaround.zip](https://issues.apache.org/jira/secure/attachment/12714888/MCOMPILER-97-workaround.zip) (_5.98 kB_)
**Issue Links:**
- [MCOMPILER-134](https://issues.apache.org/jira/browse/MCOMPILER-134) add support for jdk 6 javac -processorpath parameter
- [MCOMPILER-98](https://issues.apache.org/jira/browse/MCOMPILER-98) -sourcepath not passed to javac
(_**"is depended upon by"**_)
13 votes, 24 watchers
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.