JLLeitschuh / ktlint-gradle

A ktlint gradle plugin
MIT License
1.45k stars 159 forks source link

Ktlint creates tasks eagerly #525

Open matejdro opened 3 years ago

matejdro commented 3 years ago

It seems like ktlint creates its tasks eagerly some time after initializing them lazily.

Running ./gradlew :samples:kotlin-ks:help -Dorg.gradle.internal.tasks.stats example from https://github.com/JLLeitschuh/ktlint-gradle/pull/186 will show that ktlint tasks were created:

Task types that were registered with the new API but were created anyways
class org.gradle.api.DefaultTask 11
class org.jlleitschuh.gradle.ktlint.tasks.GenerateReportsTask 6
class org.jlleitschuh.gradle.ktlint.tasks.KtLintCheckTask 3
class org.jlleitschuh.gradle.ktlint.tasks.KtLintFormatTask 3

This is with version https://github.com/JLLeitschuh/ktlint-gradle/commit/2d8f427fba07ec60a109a291512fa2e2c73a40d3.

Tapchicoma commented 3 years ago

We have test that should check such behaviour :thinking:

@JLLeitschuh could you check if this test is enough?

Also I've noticed that Task types that were registered with the new API but were created anyways message in the report is printed twice - first time for all task types in the project and second time only for some of them. And second time message does not contain any plugin tasks.

JLLeitschuh commented 3 years ago

@JLLeitschuh could you check if this test is enough?

Not at this time, sorry, ktlint-gradle is a bit on the back burner for me at this time. I'm happy to continue to review PRs, but this isn't something I can commit to at this time.