-
-
Notifications
You must be signed in to change notification settings - Fork 119
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
Can't use YarnTask using Gradle lazy configuration API #39
Comments
Here's the Gradle folks' recommendation on how to fix this:
|
I think we can quickly get rid of half of the afterEvalute, the section here YarnTask.groovy#L36-39 Could probably be moved to the |
Apparently not, if we do that then the up-to-date detection breaks. |
Yes, but as discussed in #40, we are probably going to remove the working directory from the task inputs, because it causes unwanted rebuilds. If we do that, this will probably remove the issue you are facing. |
I pushed a first commit that removed the usages of But I would like to go a bit further and always use this configuration avoidance API. The |
Yes, there is another afterEvaluate in https://docs.gradle.org/current/userguide/lazy_configuration.html#sec:connecting_properties_together |
I could replace all the afterEvaluate usages by the configuration API but it is not sufficient to solve the issue. In some basic cases, it works. But in the case a task is not created lazily, for instance because it is referenced directly by another one (without using a task provider), the configuration will be invoked before the Gradle configuration evaluation and the task will be configured with the default configuration and will not take into account the custom configuration. You are right, in order to fix this issue, we have to use the I suggest we do it in the next major version. The issue #17 proposes to rewrite the code in Kotlin, the static typing will help us doing this refactoring. |
- Change the packages layout - Clean and simplify some code - Change the way exec runner works. Use as many mutable data structures as possible - Remove all the unnecessary after project evaluation's hook usages in tasks (issue #39)
I just pushed a big refactoring that enabled me to remove nearly all usages of It sounds like the issue is now fixed. I improved the Kotlin DSL integration test to ensure that your use case works and it works. I did not have to use Gradle's I wonder whether we should use them or not. If we have to use them, we should do it now because we already broke backwards compatibility. It does not change anything with the Groovy DSL but with the Kotlin DSL we have to replace |
Fantastic! I think Properties are indeed to way to go forward for setting properties, compatible with Gradle's lazy task configuration. |
Sorry @jfbibeau , I'm not sure I understood what you mean, probably because my english is not very good. Do you think we should use properties right now or not? |
No worries, yes, I think we should use Properties, instead of getting values from an extension. |
if |
Thanks for your answers. I am ok to work on that but I still have some questions. Wrapping all task properties in the But I don't know what to do with the If we use properties in the That would be nice to maintain the Do you see what I mean? Do you have any tips regarding this issue? Or any alternative solution? Thanks! |
There's some good examples of this in the Gradle docs, including with a project extension: I think Variant as it is coded today would probably have to change significantly. |
…n API with all tasks. (cherry picked from commit 36ffe6b)
The
YarnTask
class has aproject.afterEvaluate
call in the constructor, which conflicts with the Gradle task configuration avoidance concept (https://docs.gradle.org/current/userguide/task_configuration_avoidance.html).Specifically:
Reproduction scenario, simple project:
Execute
gradlew runSomething
.Result:
Can we remove the
project.afterEvaluate
call from theYarnTask
constructor to enable using this plugin with the lazy task API (which is now the default in Gradle)?Let me know if you need more details!
The text was updated successfully, but these errors were encountered: