Reputation: 1409
I'm revisiting a maven project that I haven't touched in at least a year. I'm pretty sure it was compiling successfully when I left it (there was still a working jar in the target
directory), but now compilation fails because generated classes are missing.
target/generated-sources/annotations
(none present)-proc:none
(it wasn't)mvn clean dependency:unpack-dependencies -Dmdep.useSubDirectoryPerArtifact=true
to ensure the expected dependencies are on the classpath and that they contain a valid META-INF/services/javax.annotation.processing.Processor
entry (yes there were multiple, including org.immutables.processor.ProxyProcessor
)-nowarn
option and add -verbose -XprintRounds -XprintProcessorInfo -Xlint -J-verbose
. NOTE: I also had to add the relative path to the main class, or javac would complain there are no sources.-proc:only
option to javac command-processor org.immutables.processor.ProxyProcessor
to javac command (processor now loaded, but still no rounds printed and no classes generated)-processor org.immutables.processor.ProxyProcessorXXX
to see if it would make a difference (it did, it now printed a warning stating that processing was requested with proc:only
, but no processors were found)-processor
option, which should make javac detect processors from class path (it didn't show the warning, which suggests it's detecting processors yet the log doesn't show any sign of it)This is the javac command I'm currently using:
javac
-d ./target/classes
-classpath ./target/classes:$HOME/.m2/repository/com/google/dagger/dagger/2.4/dagger-2.4.jar:$HOME/.m2/repository/com/google/dagger/dagger-compiler/2.4/dagger-compiler-2.4.jar:$HOME/.m2/repository/com/google/auto/factory/auto-factory/1.0-beta3/auto-factory-1.0-beta3.jar:$HOME/.m2/repository/org/immutables/builder/2.3.9/builder-2.3.9.jar:$HOME/.m2/repository/org/immutables/value/2.3.9/value-2.3.9.jar:<LONG LIST OF DIRECT AND TRANSITIVE DEPENDENCIES HERE>
-sourcepath ./src/main/java:
-s ./target/generated-sources/annotations
-verbose
-XprintRounds
-XprintProcessorInfo
-Xlint
-J-verbose
-processor org.immutables.processor.ProxyProcessor
-proc:only
./src/main/java/com/mycompany/myproject/Main.java
NOTE: for better readability, I put each argument on a new line, replaced absolute paths with $HOME/
and ./
and I omitted most dependencies.
What am I missing here? Any suggestions or pointers would be greatly appreciated.
Upvotes: 6
Views: 4305
Reputation: 2477
javac
appears to completely and silently skip annotation processing for some parse failures.
For me a duplicated annotation caused by a merge mistake caused thousands of failures because my annotation processors didn't run - so the real error got completely lost.
@Data @AllArgsConstructor @NoArgsConstructor @EqualsAndHashCode(callSuper = false)
@EqualsAndHashCode(callSuper = false)
Upvotes: 4
Reputation: 750
We had the same issue on a git branch, while the main branch built fine. The root cause turned out to be a .java source with a duplicate definition of a private void function. This duplicate was caused by a merge from the main branch. At first we did not notice it, because the merge did not cause conflicts. The problem occurred with Amazon Corretto 8 and 11 compilers. After removing the duplicate private void function, the java compiler started generating sources as before.
Upvotes: 0
Reputation: 1594
As far as I can remember maven generates a marker file or marker directory (starting with a dot) for generated sources. But it's also a long time ago...
Upvotes: 0