Using Google Error_prone compiler with Gradle

Hi,

A few months ago I created a gradle-errorprone-plugin to use Google’s error_prone compiler in Gradle.

It uses internal APIs (‘IncrementalJavaCompiler’ in Gradle <= 1.11, now ‘CleaningJavaCompiler’ in Gradle 1.12) and makes use ‘setJavaCompiler’ of the ‘JavaCompiler’ task.

This last method is deprecated in Gradle 1.12 and has already been removed in master.

I knew that by using internal APIs the plugin could break at any time; but I’d like to know if there’s any way to build such a plugin for Gradle.next, and if not, ask that some API be added to make it possible.

The next version of error_prone will support the ‘javax.tool.JavaCompiler’ API so maybe there could be some factory for ‘javax.tool.JavaCompiler’ that could be set on the ‘JavaCompiler’ task, the default one using ‘ToolProvider.getSystemJavaCompiler()’.

Thanks for the suggestion. I’ve filed GRADLE-3085 for this.

Thanks.

BTW, IntelliJ has such a factory, which is used for the ErrorProne plugin: https://github.com/JetBrains/intellij-plugins/blob/master/error-prone/jps-plugin/src/org/intellij/errorProne/ErrorProneJavaCompilingTool.java

We’re working on making it possible to register and configure multiple Java “Tool Chains” (JDKs), as well as making it possible to build several different variants of a Java library.

This work is being done in the context of the new jvm-component plugins, which will form the basis for future Android, Scala, Groovy and Java plugins. Expect to see the first public announcement of this pretty soon.

Thank you.

Do you think it would be possible to use setToolchain on the JavaCompile task in Gradle 2.1 (implementing JavaToolchainInternal) pending full toolchain support?