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

Task creation avoidance #165

Closed
daanschipper opened this issue Oct 8, 2019 · 5 comments
Closed

Task creation avoidance #165

daanschipper opened this issue Oct 8, 2019 · 5 comments

Comments

@daanschipper
Copy link
Contributor

For every sourceSet, spotbugs-gradle-plugin creates a spotbugsSourceSetName task which is created during configuration. This hurts performance for larger projects with multiple source sets, as 1000+ tasks are created.

I've pinpointed the task creation to the method com.github.spotbugs.SpotBugsPlugin.verify(), where the task objects are instantiated with p.getTasks().withType(SpotBugsTask.class).forEach(task ->.

@KengoTODA
Copy link
Member

This is the behaviour comes from Gradle official code quality plugin mechanism, such as https://github.com/gradle/gradle/blob/master/subprojects/code-quality/src/main/groovy/org/gradle/api/plugins/quality/internal/AbstractCodeQualityPlugin.java

Then you have two options:

  1. Ask Gradle itself to improve performance in your case, or
  2. Contribute to bring Breaking change required: reduce dependency on Gradle internal API #104 into reality.

@daanschipper
Copy link
Contributor Author

No, that is not true. I've commented out project.afterEvaluate(this::verify); and recompiled, after that the tasks are not created.

To add, other tasks extending the AbstractCodeQualityPlugin do also not create tasks, eg Checkstyle

@KengoTODA
Copy link
Member

Right, the change 578b7a1 is introduced only to SpotBugs plugin, and it seems that other code quality plugin no longer extends beforeApply().

@KengoTODA KengoTODA reopened this Oct 8, 2019
@KengoTODA
Copy link
Member

BTW which tasks do you mean? In my understanding CheckStylePlugin still creates tasks for each source set.

@daanschipper
Copy link
Contributor Author

This is regarding creation the actual Task object, which you want to avoid during configuration time. With project.register, from the link you provided, you only create a TaskProvider object.

You can check this yourself by running ./gradlew help --scan, under 'Performance' -> 'Configuration' you can see how many tasks are created during configuration. For example, see this build scan.

KengoTODA added a commit that referenced this issue Oct 12, 2019
current way create tesk instances even though it is not necessary.
this change applies the same way with the official CodeNarc plugin
validating configuration in setter method:
https://github.com/gradle/gradle/blob/df7ac484a2facbb4503ba911666367de22b1d16a/subprojects/code-quality/src/main/groovy/org/gradle/api/plugins/quality/CodeNarcExtension.java
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