-
Notifications
You must be signed in to change notification settings - Fork 33
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
ErrorProne plugin configures Java tasks at the execution time #97
Comments
The problem I have is that whether to force forking or not depends on whether the task uses a toolchain that is the same as the current JVM (and its version), so this can only be determined late (and at a minimum later than the plugin application). WDYT? |
The idea with validation is that it could change the strategy and not auto correct value for the user, but user would be forced to set a fork option. So if it's not correctly set, you fail a build in But if that is too annoying, I guess the only option is to use A question: What would change if plugin would set
I believe that issue from a link is only a problem for properties that are outputs (could be wrong though). In such case you can use FileSystemLocationProperty.getLocationOnly(). I think something like:
could work for you. |
Understood, but I'd like to avoid this as it adds friction given most users would have to configure forking (see below), so
Is this a blocker for you? What if I update the plugin for Gradle 9 asap? I'd rather do that than add friction for users if possible. Do I understand correctly that with Gradle 9 BTW, with lazy properties, can we set a value that depends on possibly previously set value? (i.e. do something equivalent to
Yes, for most users nowadays it would force forking. Cases where it would not are:
The reasons I didn't want to unconditionally fork are:
Now if you think those are "bad reasons", I'm open to change things (it would likely simplify the plugin's code too)
TIL about |
This is only blocker for us in a sense that we run smoke tests for ErrorProne Gradle plugin, so these fail atm. And I would guess also building Gradle itself with Gradle 9 will fail since we use ErrorProne. What if you change logic to something like:
That way Would that be an acceptable solution for you for now? That will basically make it work the same as now for Gradle <= 8 and with Gradle 9 it will fail, only if
For Gradle 9 we plan to remove a setter and change
That way in
If your plugin is compiled with Gradle <= 8 we will "upgrade" your plugin (transform bytecode), so if it contains code like:
it will be changed on a bytecode level to:
and that way old plugins will be binary compatible with Gradle 9. That is currently what we are experimenting.
We will probably add some |
This is in preparation for Gradle 9 that will change isFork to a lazy property (and dynamically rewrite the plugin bytecode) which will make it immutable at execution time. With this change, users can manually configure isFork=true when needed to avoid the error, as the plugin will no longer try to set isFork to true if it already is. This is a first step towards fixing #97
🤦♂️ Indeed! Just released version 4.0.1 with this change.
I'll keep this issue open until then. |
Awesome, thanks! 🎉 |
In Gradle 9.0 we plan to migrate majority of JVM plugins to lazy properties. We plan to bridge old raw type methods to new lazy methods on the bytecode level for old plugins, so they will be bytecode compatible. But we cannot bridge some of the behaviours.
While upgrading CompileOptions.isFork() to lazy
Property<Boolean>
type, we've noticed via smoke tests that ErrorProne sets fork option at the execution time indoFirst
block. WithProperty<Boolean>
that becomes an error, sinceProperty
is finalized and can't be changed at execution time, so upgrade to lazy property breaksErrorProne
plugin.One solution that could work here for you, is that you configure
CompileOptions.isFork
at configuration time and then you validate the value at the execution time and fail if it's not set to true, see also gradle/gradle#25836 (comment).Would be possible to change the behaviour that way?
The error that is reported after property upgrade to a lazy property:
The text was updated successfully, but these errors were encountered: