ktlint-gradle
ktlint-gradle copied to clipboard
Add support for project isolation.
The plugin doesn't appear to be compatible with project isolation (https://docs.gradle.org/current/userguide/isolated_projects.html) : The problem is with this bit of code here: https://github.com/JLLeitschuh/ktlint-gradle/blob/818098d7a716384dfed69d6f019c7c05a2f60d85/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/TaskCreation.kt#L45
Thanks for bringing this up. I think we will need to remove this bit, and if you want your root build script linted, you will need to apply the plugin directly there. We will need to investigate if this could cause other issues
- https://github.com/JLLeitschuh/ktlint-gradle/pull/480
- https://github.com/JLLeitschuh/ktlint-gradle/commit/ccc2ee1fa44d2a21f26d1dcde9ac92fe88f54378
@pvegh looks like that pig came back looking for it's lipstick 😆
https://github.com/JLLeitschuh/ktlint-gradle/pull/480#issuecomment-852153773
I just tried with the latest gradle 9.1.0 and latest plugin and am getting the following:
- [error] Project `:services:auth:api` cannot dynamically look up a property in the parent project `:services:auth`
- property `internalKtlintGitFilter` of `:services:auth:api`
- project `:services:auth:api`
- plugin 'org.jlleitschuh.gradle.ktlint'
- Exception at `org.jlleitschuh.gradle.ktlint.tasks.BaseKtLintCheckTask.<init>(BaseKtLintCheckTask.kt:94)`
org.gradle.api.InvalidUserCodeException: Project ':services:auth:api' cannot dynamically look up a property in the parent project ':services:auth'
at org.gradle.api.internal.project.DefaultProject.hasProperty(DefaultProject.java:1234)
at org.jlleitschuh.gradle.ktlint.tasks.BaseKtLintCheckTask.<init>(BaseKtLintCheckTask.kt:94)
at org.jlleitschuh.gradle.ktlint.tasks.KtLintCheckTask.<init>(KtLintCheckTask.kt:19)
at org.jlleitschuh.gradle.ktlint.tasks.KtLintCheckTask_Decorated.<init>(Unknown Source)
at org.gradle.api.internal.DefaultNamedDomainObjectCollection$AbstractDomainObjectCreatingProvider.get(DefaultNamedDomainObjectCollection.java:976)
at org.jlleitschuh.gradle.ktlint.TaskCreationKt.commonConfiguration(TaskCreation.kt:176)
at org.jlleitschuh.gradle.ktlint.TaskCreationKt.access$commonConfiguration(TaskCreation.kt:1)
at org.jlleitschuh.gradle.ktlint.TaskCreationKt$createGenerateReportsTask$1.invoke(TaskCreation.kt:153)
at org.jlleitschuh.gradle.ktlint.TaskCreationKt$createGenerateReportsTask$1.invoke(TaskCreation.kt:148)
at org.jlleitschuh.gradle.ktlint.PluginUtilKt$sam$i$org_gradle_api_Action$0.execute(PluginUtil.kt)
at java.base/java.lang.Thread.run(Thread.java:1583)
- Exception at `org.jlleitschuh.gradle.ktlint.tasks.BaseKtLintCheckTask.<init>(BaseKtLintCheckTask.kt:94)`
- Gradle runtime
- Exception at `org.jlleitschuh.gradle.ktlint.tasks.BaseKtLintCheckTask.<init>(BaseKtLintCheckTask.kt:94)`
org.gradle.api.InvalidUserCodeException: Project ':services:auth:api' cannot dynamically look up a property in the parent project ':services:auth'
at org.gradle.api.internal.project.DefaultProject.hasProperty(DefaultProject.java:1234)
at org.jlleitschuh.gradle.ktlint.tasks.BaseKtLintCheckTask.<init>(BaseKtLintCheckTask.kt:94)
at org.jlleitschuh.gradle.ktlint.tasks.KtLintFormatTask.<init>(KtLintFormatTask.kt:23)
at org.jlleitschuh.gradle.ktlint.tasks.KtLintFormatTask_Decorated.<init>(Unknown Source)
at java.base/java.lang.Thread.run(Thread.java:1583)`
Looks like the problem is here: https://github.com/JLLeitschuh/ktlint-gradle/blob/main/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/tasks/BaseKtLintCheckTask.kt#L94
Looks like the problem is here: https://github.com/JLLeitschuh/ktlint-gradle/blob/main/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/tasks/BaseKtLintCheckTask.kt#L94
Yep accessing the project model from a task is deprecated. This one should be easy enough to fix. I can take a look
Fixed the formatting on your stack trace.
In general, please wrap your stack traces in code blocks, it makes them readable 😂