Open sos-jira-migration-bot[bot] opened 4 years ago
Delany commented
This is a problem with errorprone 2.4.0. I updated it to 2.16, ran it on JDK17
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project maven-compiler-plugin-error-prone: Fatal error compiling: -XepPatchChecks and -XepPatchLocation must be specified together
Rocher Suchard commented
I don't know what feedback you are waiting for, but as far as I remember, the issue is not about errorprone in itself, it is about the behaviour of Compiler plugin when a Toolchains is used : the error message change drastically in this case.
I updated the sample project using latest version of Maven and Plugins : [^maven-compiler-plugin-3.13.0-error-prone.zip]
I did not update the ErrorProne version because I don't think that's necessary to test this : only a JDK 11 is required.
This can be tested either by installing a JDK 11 + 17 locally, either via Docker :
apt install -y wget apt-transport-https gpg
wget -qO - https://packages.adoptium.net/artifactory/api/gpg/key/public | gpg --dearmor | tee /etc/apt/trusted.gpg.d/adoptium.gpg > /dev/null
echo "deb https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" | tee /etc/apt/sources.list.d/adoptium.list
apt -y update
apt -y install temurin-11-jdk
mvn wrapper:wrapper -Dmaven=3.9.9
1. fail with a proper error message
java -version # should be 11
./mvnw -ntp verify
1. because toolchains is now smart to not use a toolchains if current=target
apt -y install temurin-17-jdk
java -version # should be 17
./mvnw verify -ntp -Puse-toolchain
When we do not use the toolchains, or when the toolchains == current JVM :
[INFO] --- compiler:3.13.0:compile (default-compile) @ maven-compiler-plugin-error-prone ---
[WARNING] Error while writing new mojo status: /home/glhez/maven-compiler-plugin-3.13.0-error-prone/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
[INFO] Recompiling the module because of changed source code.
[INFO] Compiling 1 source file with javac [debug deprecation parameters release 11] to target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.108 s
[INFO] Finished at: 2025-02-17T19:33:12+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.13.0:compile (default-compile) on project maven-compiler-plugin-error-prone: Fatal error compiling: -XepPatchChecks and -XepPatchLocation must be specified together -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
The error is clear and I, as an user, know what to look for.
When a toolchain is used and the current Java is Java 17 :
[INFO] --- compiler:3.13.0:compile (default-compile) @ maven-compiler-plugin-error-prone ---
[INFO] Toolchain in maven-compiler-plugin: JDK[/usr/lib/jvm/temurin-11-jdk-amd64]
[INFO] Recompiling the module because of changed source code.
[INFO] Compiling 1 source file with javac [forked debug deprecation parameters release 11] to target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] at jdk.compiler/com.sun.tools.javac.api.BasicJavacTask.initPlugins(BasicJavacTask.java:217)
at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:285)
at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:170)
at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:57)
at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:43)
Caused by: com.google.errorprone.InvalidCommandLineOptionException: -XepPatchChecks and -XepPatchLocation must be specified together
at com.google.errorprone.ErrorProneOptions$PatchingOptions$Builder.build(ErrorProneOptions.java:149)
at com.google.errorprone.ErrorProneOptions$Builder.build(ErrorProneOptions.java:356)
at com.google.errorprone.ErrorProneOptions.processArgs(ErrorProneOptions.java:469)
at com.google.errorprone.ErrorProneOptions.processArgs(ErrorProneOptions.java:482)
at com.google.errorprone.ErrorProneJavacPlugin.init(ErrorProneJavacPlugin.java:45)
at jdk.compiler/com.sun.tools.javac.api.BasicJavacTask.initPlugins(BasicJavacTask.java:215)
... 4 more
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.728 s
[INFO] Finished at: 2025-02-17T19:34:41+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.13.0:compile (default-compile) on project maven-compiler-plugin-error-prone: Compilation failure
[ERROR] at jdk.compiler/com.sun.tools.javac.api.BasicJavacTask.initPlugins(BasicJavacTask.java:217)
[ERROR] at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:285)
[ERROR] at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:170)
[ERROR] at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:57)
[ERROR] at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:43)
[ERROR] Caused by: com.google.errorprone.InvalidCommandLineOptionException: -XepPatchChecks and -XepPatchLocation must be specified together
[ERROR] at com.google.errorprone.ErrorProneOptions$PatchingOptions$Builder.build(ErrorProneOptions.java:149)
[ERROR] at com.google.errorprone.ErrorProneOptions$Builder.build(ErrorProneOptions.java:356)
[ERROR] at com.google.errorprone.ErrorProneOptions.processArgs(ErrorProneOptions.java:469)
[ERROR] at com.google.errorprone.ErrorProneOptions.processArgs(ErrorProneOptions.java:482)
[ERROR] at com.google.errorprone.ErrorProneJavacPlugin.init(ErrorProneJavacPlugin.java:45)
[ERROR] at jdk.compiler/com.sun.tools.javac.api.BasicJavacTask.initPlugins(BasicJavacTask.java:215)
[ERROR] ... 4 more
[ERROR]
[ERROR]
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
The error did change a bit since 3.8.1 and I can read the actual error, but as an user, but this is not handled the same at all .
Slawomir Jaranowski commented
Rocher Suchard Thanks for explanation
The different of error handles can be in https://github.com/codehaus-plexus/plexus-compiler project also.
Rocher Suchard opened MCOMPILER-435 and commented
Hello,
I followed ErrorProne installation (http://errorprone.info/docs/installation and http://errorprone.info/docs/patching) but I did not provide a
-XepPatchCheck
which result in an error thatmaven-compiler-plugin
fails to report when a toolchain is used:Without a toolchain, I get this error which is what I expect, eg: something that helps!
With a JDK 11 toolchain, the error won't help, neither the (huge) stacktrace when using
-e
.maven-compiler-plugin
is unable to report correctly thecom.google.errorprone.InvalidCommandLineOptionException
thrown by ErrorProne when a toolchain is used (in this case, the toolchain is useless, but I have profile with Java 15).The attached file contains a sample project:
./mvnw clean install
./mvnw -Puse-toolchain clean install
Java 11 is both required to build, and as a toolchain.
Affects: 3.8.1
Attachments: