Skip to content

Could not get unknown property 'errorprone' for object of type org.gradle.api.tasks.compile.CompileOptions. #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
boris-petrov opened this issue May 14, 2018 · 4 comments
Milestone

Comments

@boris-petrov
Copy link

boris-petrov commented May 14, 2018

I've been using the other plugin until now (net.ltgt.errorprone) but I decided to give this one a try with JDK9. I only change id 'net.ltgt.errorprone' version '0.0.14' to id 'net.ltgt.errorprone-javacplugin' version '0.2' and add options.errorprone.disableWarningsInGeneratedCode = true in my tasks.withType(JavaCompile) and I get the error from the title:

Could not get unknown property 'errorprone' for object of type org.gradle.api.tasks.compile.CompileOptions.

I'm not sure what I am doing wrong. Any ideas?

P.S. JDK 9.0.4 and Gradle 4.7.

@tbroyer
Copy link
Owner

tbroyer commented May 14, 2018

I cannot reproduce; can you share a project that reproduces the issue? What other plugins are you using? (including the built-in ones such as the java or java-library plugin)

@boris-petrov
Copy link
Author

I thought it could be because of another plugin. And yes, it is. Adding id 'me.champeau.gradle.jmh' version '0.4.5' breaks it. Any ideas why and where the problem might be?

@tbroyer
Copy link
Owner

tbroyer commented May 14, 2018

me.champeau.gradle.jmh plugin creates a jmhCompileGeneratedClasses JavaCompile task that's not "linked" to any source set, so the extension is not automatically applied to it, as its options.annotationProcessorPath is not guaranteed to be set to contain Error Prone (and indeed it's left empty/null). You need to explicitly enable Error Prone on that task if you want it, and set its options.annotationProcessorPath. Something like:

jmhCompileGeneratedClasses {
  ErrorProneJavacPlugin.apply(options)
  options.annotationProcessorPath = configurations.errorprone
}

Then you'll be able to use options.errorprone.… in your tasks.withType(JavaCompile).

See the note about “custom JavaCompile tasks” in the README.

@tbroyer tbroyer closed this as completed May 14, 2018
@tbroyer tbroyer added the invalid This doesn't seem right label May 14, 2018
tbroyer added a commit that referenced this issue Aug 24, 2018
…and only enable Error Prone where we used to create the extension.

This means that custom JavaCompile tasks (such as the one created
by the 'me.champeau.gradle.jmh' plugin, see issue #3) now have the
extension and can be configured in a tasks.withType(JavaCompile)
closure, but that configuration will be ignored unless Error Prone
is explicitly enabled on those tasks.

Also, remove the ErrorProneJavacPlugin.apply() API; plugin needs
to be applied to be useful (not only present in the build classpath)
@tbroyer
Copy link
Owner

tbroyer commented Aug 24, 2018

Fwiw, I just published v0.4 that applies the options.errorprone extension to all JavaCompile tasks, so tasks.withType(JavaCompile) { options.errorprone { … } } will no longer fail, even in the presence of the JMH plugin. For tasks that are not "linked" to a source set, options.errorprone.enabled defaults to false, so the JMH task won't use Error Prone. If you want it to use Error Prone too, then you can do:

jmhCompileGeneratedClasses {
  options.annotationProcessorPath = configurations.errorprone
  options.errorprone.enabled = true
}

README has been updated.

(also please note that ErrorProneJavacPlugin.apply(options) API has been removed)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants