Make use of Gradle Task Configuration Avoidance for registering tasks #210
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR improves the plugin by registering tasks using Task Configuration Avoidance.
In a nutshell, the changes will register the Gradle tasks, but they will only be configured if they are actually required (i.e. when they will actually be executed), improving the time Gradle takes to configure everything.
I noticed that the plugin was configuring
downloadLicenses
,license
andlicenseFormat
tasks even if a small Gradle task was run.For demo purposes, I created a small demo project, which defines three modules, each having a simple
helloWorld
task whose only purpose is to print something to the console:LicenseGradlePluginLazyTaskConfigurationSample.zip
The project prints the tasks that are configured by Gradle to the console.
When running
./gradlew :module1:helloWorld
with the latest released plugin version, the console output looks as follows:As you can see,
downloadLicenses
,license
andlicenseFormat
tasks are configured even if they are not run, also for modules that are not affected by the current Gradle run.After my changes, the output looks as follows: