Problem
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.
What I tried
- Verified there are indeed no sources in
target/generated-sources/annotations
(none present) - Ensured javac wasn't invoked with
-proc:none
(it wasn't) - Ran
mvn clean dependency:unpack-dependencies -Dmdep.useSubDirectoryPerArtifact=true
to ensure the expected dependencies are on the classpath and that they contain a validMETA-INF/services/javax.annotation.processing.Processor
entry (yes there were multiple, includingorg.immutables.processor.ProxyProcessor
) - Followed these steps from How to make sure javac is using an annotation processor and troubleshoot when it is not:
- Take the javac options from the maven debug log
- Remove
-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. - Verify if class of processor is loaded (not present)
- Look for at least one processing round log (none present)
- Make sure annotations are present in the list of the round log (no round log)
- Added
-proc:only
option to javac command - Also added
-processor org.immutables.processor.ProxyProcessor
to javac command (processor now loaded, but still no rounds printed and no classes generated) - Changed the processor option to
-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 withproc:only
, but no processors were found) - Checked to see if that warning appeared if I didn't use the
-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) - Tried above after switching from JDK1.8 to JDK9 (using jenv)
- Installed Zulu 1.7 and tried above after switching to it (using jenv)
Possible factors
- I did an entirely clean install of macOS
- I ran macOS Sierra before, currently High Sierra
- Before I didn't have JDK9 installed
- I switched to using Gradle a long time ago, so I might have forgotten an important detail about maven
Command options
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.
Question
What am I missing here? Any suggestions or pointers would be greatly appreciated.
-Xmaxerrs 100000
(I also added-Xmaxwarns 100000
), or javac might not print the most relevant information because it's past the default error/warning limit. I tried that with Maven too, but unfortunately it has trouble handling these flags: stackoverflow.com/a/3358578 – Leninist