mill icon indicating copy to clipboard operation
mill copied to clipboard

ErrorProne 2.36.0 and above fails with InvalidCommandLineOptionException

Open asarkar opened this issue 1 year ago • 0 comments

Given the following build.mill:

package build
import mill._, javalib._, errorprone._, checkstyle._
import mill.javalib.palantirformat._

trait MyModule extends JavaModule with ErrorProneModule with CheckstyleModule with PalantirFormatModule {
  def errorProneVersion = "2.37.0"
  def checkstyleVersion = "10.23.0"
  def palantirformatVersion = "2.63.0"
  override def checkstyleConfig = Task {
    api.PathRef(Task.workspace / "checkstyle-config.xml")
  }

  object test extends JavaTests with TestModule.Junit5
}

object foo extends MyModule

Running ./mill __.compile fails with the following exception.

[57/61] foo.compile
[57] [info] compiling 1 Java source to .../compile.dest/classes ...
[57] [warn] Unexpected javac output: Exception in thread "main" com.sun.tools.javac.util.PropagatedException: com.google.errorprone.InvalidCommandLineOptionException: The default --should-stop=ifError policy (INIT) is not supported by Error Prone, pass --should-stop=ifError=FLOW instead
[57] [warn] 	at jdk.compiler/com.sun.tools.javac.api.BasicJavacTask.initPlugins(BasicJavacTask.java:231)
[57] [warn] 	at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:292)
[57] [warn] 	at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:176)
[57] [warn] 	at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:64)
[57] [warn] 	at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:50)
[57] [warn] Caused by: com.google.errorprone.InvalidCommandLineOptionException: The default --should-stop=ifError policy (INIT) is not supported by Error Prone, pass --should-stop=ifError=FLOW instead
[57] [warn] 	at com.google.errorprone.BaseErrorProneJavaCompiler.checkShouldStopIfErrorPolicy(BaseErrorProneJavaCompiler.java:197)
[57] [warn] 	at com.google.errorprone.BaseErrorProneJavaCompiler.addTaskListener(BaseErrorProneJavaCompiler.java:87)
[57] [warn] 	at com.google.errorprone.ErrorProneJavacPlugin.init(ErrorProneJavacPlugin.java:34)
[57] [warn] 	at jdk.compiler/com.sun.tools.javac.api.BasicJavacTask.initPlugin(BasicJavacTask.java:255)
[57] [warn] 	at jdk.compiler/com.sun.tools.javac.api.BasicJavacTask.initPlugins(BasicJavacTask.java:229)
[57] [warn] 	... 4 more.
[57] [warn] javac exited with exit code 1

It appears this option is supposed to be passed as a compiler argument as documented in this ticket.

The build can be unblocked by adding the following to the build.mill:

def javacOptions = Seq("--should-stop=ifError=FLOW")

However, this is tedious, and undocumented (by mill). This ticket asks for this option to be added to the ErrorProneModule.

asarkar avatar Apr 12 '25 19:04 asarkar