Skip to content
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

Consider using Gradle's configuration avoidance API #355

Open
celcius112 opened this issue Nov 7, 2019 · 2 comments
Open

Consider using Gradle's configuration avoidance API #355

celcius112 opened this issue Nov 7, 2019 · 2 comments

Comments

@celcius112
Copy link

celcius112 commented Nov 7, 2019

Since last year there's a new Gradle API for registering tasks called the 'Configuration Avoidance API'. This API was incubating from Gradle 4.9 to Gradle 5.1 inclusively, but since 5.0 has been quite stable.

This API basically lets us defined tasks configuration lazily so that they are configured only if needed. While a tasks.create("myEagerTask") would always launch myEagerTask configuration, a tasks.register("myLazyTask) would configure it only if necessary. For instance launching the simple ./gradlew help would configure myEagerTask even though they are not related, but will not configure myLazyTask. Similarly, launching ./gradlew myLazyTask will configure myLazyTask and myEagerTask.

The nodeplugin configures all tasks eagerly. Their configurations does not take too much time (a ./gradlew help --scan shows they are configured in 0.4sec), but little by little, by using other plugins that aren't using this new API, we end up with several unnecessary tasks configured eagerly. It is also worth noting that the create API will one day be deprecated.

Since this API is only usable after Gradle 4.9, using it might bring breaking changes to the users. I don't see a minimum version recommendation for the node plugin, so before proposing a PR I wanted to discuss a bit about it.
I see two solutions:

  • Only configure lazily if the user is using Gradle >4.9
  • Always configure lazily but setting the minimum Gradle version to 4.9. This is my preferred solution since Gradle 6 is coming pretty soon
@dawi
Copy link

dawi commented Nov 7, 2019

Maybe have a look at https://github.com/node-gradle/gradle-node-plugin which is an actively maintained fork of this project. :) More Info: #315

@celcius112
Copy link
Author

oh that's good to know, thanks for the heads up ! Seems like there's already some work in progress for using the configuration avoidance API. I'll keep this issue open just in case though.

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