Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update RewritePlugin to load tasks lazily (#326)
Motivation ---------- The current structure of RewritePlugin eagerly loads the RewriteRun, RewriteDryRun, and RewriteDiscover tasks. This is a problem in Gradle builds with a large number of modules, as it has to create hundreds or even thousands of tasks during configuration. This will happen even if the tasks are not used in that run. This commit updates the plugin by lazily loading these tasks to avoid this issue. Modifications ------------- The RewritePlugin was changed to call the register() method instead of the create() method for the three tasks. This method takes a configuration lambda where the existing configuration can be done. Next, the tasks' usages were replaced with the equivalent TaskProvider reference. Finally, fetching the appropriate JavaCompile tasks was updated to use a lazy load method (named()), so those tasks are not eagerly created. The plugin's Gradle version was unchanged and should still support Gradle 4.10. Result ------ The result is a RewritePlugin that no longer eagerly loads its tasks. It is now safe to use in very large builds.
- Loading branch information