ktlint-gradle
ktlint-gradle copied to clipboard
Format task show deprecation messages in Gradle 7.0
Calling ./gradlew ktlintFormat with Gradle 7.0-milestone-3 displays:
> Task :runKtlintFormatOverMainSourceSet
Execution optimizations have been disabled for task ':runKtlintFormatOverMainSourceSet' to ensure correctness due to the following reasons:
- Gradle detected a problem with the following location: '/path/to/project/.editorconfig'. Reason: Task ':runKtlintFormatOverMainSourceSet' uses this output of task ':runKtlintFormatOverKotlinScripts' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.0-milestone-3/userguide/validation_problems.html#implicit_dependency for more details about this problem.
- Gradle detected a problem with the following location: '/path/to/project/build/intermediates/ktLint/reporters.bin'. Reason: Task ':runKtlintFormatOverMainSourceSet' uses this output of task ':runKtlintFormatOverKotlinScripts' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.0-milestone-3/userguide/validation_problems.html#implicit_dependency for more details about this problem.
- Gradle detected a problem with the following location: '/path/to/project/src/main/java'. Reason: Task ':runKtlintFormatOverMainSourceSet' uses this output of task ':runKtlintFormatOverKotlinScripts' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.0-milestone-3/userguide/validation_problems.html#implicit_dependency for more details about this problem.
- Gradle detected a problem with the following location: '/path/to/project/src/main/kotlin'. Reason: Task ':runKtlintFormatOverMainSourceSet' uses this output of task ':runKtlintFormatOverKotlinScripts' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.0-milestone-3/userguide/validation_problems.html#implicit_dependency for more details about this problem.
Gradle detected a problem with the following location: '/path/to/project/.editorconfig'. Reason: Task ':runKtlintFormatOverMainSourceSet' uses this output of task ':runKtlintFormatOverKotlinScripts' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.0-milestone-3/userguide/validation_problems.html#implicit_dependency for more details about this problem. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0. Execution optimizations are disabled to ensure correctness. See https://docs.gradle.org/7.0-milestone-3/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
Gradle detected a problem with the following location: '/path/to/project/build/intermediates/ktLint/reporters.bin'. Reason: Task ':runKtlintFormatOverMainSourceSet' uses this output of task ':runKtlintFormatOverKotlinScripts' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.0-milestone-3/userguide/validation_problems.html#implicit_dependency for more details about this problem. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0. Execution optimizations are disabled to ensure correctness. See https://docs.gradle.org/7.0-milestone-3/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
Gradle detected a problem with the following location: '/path/to/project/src/main/java'. Reason: Task ':runKtlintFormatOverMainSourceSet' uses this output of task ':runKtlintFormatOverKotlinScripts' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.0-milestone-3/userguide/validation_problems.html#implicit_dependency for more details about this problem. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0. Execution optimizations are disabled to ensure correctness. See https://docs.gradle.org/7.0-milestone-3/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
Gradle detected a problem with the following location: '/path/to/project/src/main/kotlin'. Reason: Task ':runKtlintFormatOverMainSourceSet' uses this output of task ':runKtlintFormatOverKotlinScripts' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.0-milestone-3/userguide/validation_problems.html#implicit_dependency for more details about this problem. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0. Execution optimizations are disabled to ensure correctness. See https://docs.gradle.org/7.0-milestone-3/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
> Task :ktlintMainSourceSetFormat
Execution optimizations have been disabled for task ':ktlintMainSourceSetFormat' to ensure correctness due to the following reasons:
- Gradle detected a problem with the following location: '/path/to/project/build/intermediates/ktLint/reporterProviders.bin'. Reason: Task ':ktlintMainSourceSetFormat' uses this output of task ':runKtlintFormatOverKotlinScripts' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.0-milestone-3/userguide/validation_problems.html#implicit_dependency for more details about this problem.
- Gradle detected a problem with the following location: '/path/to/project/build/intermediates/ktLint/reporters.bin'. Reason: Task ':ktlintMainSourceSetFormat' uses this output of task ':runKtlintFormatOverKotlinScripts' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.0-milestone-3/userguide/validation_problems.html#implicit_dependency for more details about this problem.
- Gradle detected a problem with the following location: '/path/to/project/build/intermediates/ktLint/runKtlintFormatOverMainSourceSet_errors.bin'. Reason: Task ':ktlintMainSourceSetFormat' uses this output of task ':runKtlintFormatOverKotlinScripts' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.0-milestone-3/userguide/validation_problems.html#implicit_dependency for more details about this problem.
Gradle detected a problem with the following location: '/path/to/project/build/intermediates/ktLint/reporterProviders.bin'. Reason: Task ':ktlintMainSourceSetFormat' uses this output of task ':runKtlintFormatOverKotlinScripts' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.0-milestone-3/userguide/validation_problems.html#implicit_dependency for more details about this problem. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0. Execution optimizations are disabled to ensure correctness. See https://docs.gradle.org/7.0-milestone-3/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
Gradle detected a problem with the following location: '/path/to/project/build/intermediates/ktLint/reporters.bin'. Reason: Task ':ktlintMainSourceSetFormat' uses this output of task ':runKtlintFormatOverKotlinScripts' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.0-milestone-3/userguide/validation_problems.html#implicit_dependency for more details about this problem. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0. Execution optimizations are disabled to ensure correctness. See https://docs.gradle.org/7.0-milestone-3/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
Gradle detected a problem with the following location: '/path/to/project/build/intermediates/ktLint/runKtlintFormatOverMainSourceSet_errors.bin'. Reason: Task ':ktlintMainSourceSetFormat' uses this output of task ':runKtlintFormatOverKotlinScripts' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.0-milestone-3/userguide/validation_problems.html#implicit_dependency for more details about this problem. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0. Execution optimizations are disabled to ensure correctness. See https://docs.gradle.org/7.0-milestone-3/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
> Task :runKtlintFormatOverTestSourceSet
Execution optimizations have been disabled for task ':runKtlintFormatOverTestSourceSet' to ensure correctness due to the following reasons:
- Gradle detected a problem with the following location: '/path/to/project/.editorconfig'. Reason: Task ':runKtlintFormatOverTestSourceSet' uses this output of task ':runKtlintFormatOverKotlinScripts' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.0-milestone-3/userguide/validation_problems.html#implicit_dependency for more details about this problem.
- Gradle detected a problem with the following location: '/path/to/project/build/intermediates/ktLint/reporters.bin'. Reason: Task ':runKtlintFormatOverTestSourceSet' uses this output of task ':runKtlintFormatOverKotlinScripts' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.0-milestone-3/userguide/validation_problems.html#implicit_dependency for more details about this problem.
- Gradle detected a problem with the following location: '/path/to/project/src/test/java'. Reason: Task ':runKtlintFormatOverTestSourceSet' uses this output of task ':runKtlintFormatOverKotlinScripts' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.0-milestone-3/userguide/validation_problems.html#implicit_dependency for more details about this problem.
- Gradle detected a problem with the following location: '/path/to/project/src/test/kotlin'. Reason: Task ':runKtlintFormatOverTestSourceSet' uses this output of task ':runKtlintFormatOverKotlinScripts' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.0-milestone-3/userguide/validation_problems.html#implicit_dependency for more details about this problem.
Gradle detected a problem with the following location: '/path/to/project/.editorconfig'. Reason: Task ':runKtlintFormatOverTestSourceSet' uses this output of task ':runKtlintFormatOverKotlinScripts' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.0-milestone-3/userguide/validation_problems.html#implicit_dependency for more details about this problem. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0. Execution optimizations are disabled to ensure correctness. See https://docs.gradle.org/7.0-milestone-3/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
Gradle detected a problem with the following location: '/path/to/project/build/intermediates/ktLint/reporters.bin'. Reason: Task ':runKtlintFormatOverTestSourceSet' uses this output of task ':runKtlintFormatOverKotlinScripts' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.0-milestone-3/userguide/validation_problems.html#implicit_dependency for more details about this problem. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0. Execution optimizations are disabled to ensure correctness. See https://docs.gradle.org/7.0-milestone-3/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
Gradle detected a problem with the following location: '/path/to/project/src/test/java'. Reason: Task ':runKtlintFormatOverTestSourceSet' uses this output of task ':runKtlintFormatOverKotlinScripts' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.0-milestone-3/userguide/validation_problems.html#implicit_dependency for more details about this problem. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0. Execution optimizations are disabled to ensure correctness. See https://docs.gradle.org/7.0-milestone-3/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
Gradle detected a problem with the following location: '/path/to/project/src/test/kotlin'. Reason: Task ':runKtlintFormatOverTestSourceSet' uses this output of task ':runKtlintFormatOverKotlinScripts' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.0-milestone-3/userguide/validation_problems.html#implicit_dependency for more details about this problem. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0. Execution optimizations are disabled to ensure correctness. See https://docs.gradle.org/7.0-milestone-3/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
> Task :ktlintTestSourceSetFormat
Execution optimizations have been disabled for task ':ktlintTestSourceSetFormat' to ensure correctness due to the following reasons:
- Gradle detected a problem with the following location: '/path/to/project/build/intermediates/ktLint/reporterProviders.bin'. Reason: Task ':ktlintTestSourceSetFormat' uses this output of task ':runKtlintFormatOverKotlinScripts' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.0-milestone-3/userguide/validation_problems.html#implicit_dependency for more details about this problem.
- Gradle detected a problem with the following location: '/path/to/project/build/intermediates/ktLint/reporters.bin'. Reason: Task ':ktlintTestSourceSetFormat' uses this output of task ':runKtlintFormatOverKotlinScripts' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.0-milestone-3/userguide/validation_problems.html#implicit_dependency for more details about this problem.
- Gradle detected a problem with the following location: '/path/to/project/build/intermediates/ktLint/runKtlintFormatOverTestSourceSet_errors.bin'. Reason: Task ':ktlintTestSourceSetFormat' uses this output of task ':runKtlintFormatOverKotlinScripts' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.0-milestone-3/userguide/validation_problems.html#implicit_dependency for more details about this problem.
Gradle detected a problem with the following location: '/path/to/project/build/intermediates/ktLint/reporterProviders.bin'. Reason: Task ':ktlintTestSourceSetFormat' uses this output of task ':runKtlintFormatOverKotlinScripts' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.0-milestone-3/userguide/validation_problems.html#implicit_dependency for more details about this problem. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0. Execution optimizations are disabled to ensure correctness. See https://docs.gradle.org/7.0-milestone-3/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
Gradle detected a problem with the following location: '/path/to/project/build/intermediates/ktLint/reporters.bin'. Reason: Task ':ktlintTestSourceSetFormat' uses this output of task ':runKtlintFormatOverKotlinScripts' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.0-milestone-3/userguide/validation_problems.html#implicit_dependency for more details about this problem. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0. Execution optimizations are disabled to ensure correctness. See https://docs.gradle.org/7.0-milestone-3/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
Gradle detected a problem with the following location: '/path/to/project/build/intermediates/ktLint/runKtlintFormatOverTestSourceSet_errors.bin'. Reason: Task ':ktlintTestSourceSetFormat' uses this output of task ':runKtlintFormatOverKotlinScripts' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.0-milestone-3/userguide/validation_problems.html#implicit_dependency for more details about this problem. This behaviour has been deprecated and is scheduled to be removed in Gradle 8.0. Execution optimizations are disabled to ensure correctness. See https://docs.gradle.org/7.0-milestone-3/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
Execution optimizations have been disabled for 4 invalid unit(s) of work during this build to ensure correctness.
Please consult deprecation warnings for more details.
BUILD SUCCESSFUL in 5s
7 actionable tasks: 7 executed
+1, not critical but annoying
Any updates?
I hope It helps (Workaround)
afterEvaluate {
[
"processResources",
"ktlintMainSourceSetFormat",
"runKtlintFormatOverMainSourceSet",
"ktlintTestSourceSetFormat",
"runKtlintFormatOverTestSourceSet",
"compileKotlin",
"ktlintKotlinScriptFormat",
"runKtlintFormatOverKotlinScripts"
].forEach { name ->
tasks.named(name).configure {
if ("runKtlintFormatOverKotlinScripts" != name) {
dependsOn("runKtlintFormatOverKotlinScripts")
}
if (project.parent != null && project.parent?.name != rootProject.name) {
dependsOn(":${project.parent?.name}:runKtlintFormatOverKotlinScripts")
}
}
}
}
Alternative workaround. It handles any source sets and any project structure. Apply it on every project that applies plugin org.jlleitschuh.gradle.ktlint:
project.tasks.withType(org.jlleitschuh.gradle.ktlint.tasks.GenerateReportsTask).configureEach {
dependsOn project.tasks.named('runKtlintFormatOverKotlinScripts')
}
project.tasks.withType(org.jlleitschuh.gradle.ktlint.tasks.KtLintFormatTask).configureEach {
if (name != 'runKtlintFormatOverKotlinScripts') {
dependsOn project.tasks.named('runKtlintFormatOverKotlinScripts')
Project parentProject = project.parent
while (parentProject != null) {
if (parentProject.name != rootProject.name && parentProject.plugins.hasPlugin('org.jlleitschuh.gradle.ktlint')) {
dependsOn("${parentProject.path}:runKtlintFormatOverKotlinScripts")
}
parentProject = parentProject.parent
}
}
}
some issue using gradle 7.0.2 and ktlint plugin 10.0.0
With merged #480 there are still plenty of warnings from format tasks
- Gradle detected a problem with the following location: 'myproj/src/main/java'.
Reason: Task ':myproj:runKtlintFormatOverMainSourceSet' uses this output of task ':runKtlintFormatOverKotlinScripts' without declaring an explicit or implicit dependency.
This can lead to incorrect results being produced, depending on what order the tasks are executed.
Please refer to https://docs.gradle.org/7.0.2/userguide/validation_problems.html#implicit_dependency for more details about this problem.
I set up dependency manually with mustRunAfter for many tasks to completely eliminate warnings:
tasks.findByPath("compileKotlin")?.let {
it.mustRunAfter("runKtlintFormatOverKotlinScripts", "runKtlintFormatOverMainSourceSet")
}
tasks.named("runKtlintFormatOverKotlinScripts").configure {
mustRunAfter(":runKtlintFormatOverKotlinScripts")
}
tasks.named("runKtlintFormatOverMainSourceSet").configure {
mustRunAfter("runKtlintFormatOverKotlinScripts", ":runKtlintFormatOverKotlinScripts")
}
tasks.findByPath("ktlintMainSourceSetFormat")
?.mustRunAfter("runKtlintFormatOverKotlinScripts", ":runKtlintFormatOverKotlinScripts")
tasks.findByPath("ktlintTestSourceSetFormat")
?.mustRunAfter("runKtlintFormatOverKotlinScripts", ":runKtlintFormatOverKotlinScripts")
tasks.findByPath("runKtlintFormatOverTestSourceSet")
?.mustRunAfter("runKtlintFormatOverKotlinScripts", ":runKtlintFormatOverKotlinScripts")
tasks.findByPath("ktlintAndroidTestSourceSetFormat")
?.mustRunAfter("runKtlintFormatOverKotlinScripts", ":runKtlintFormatOverKotlinScripts")
tasks.findByPath("runKtlintFormatOverAndroidTestSourceSet")
?.mustRunAfter("runKtlintFormatOverKotlinScripts", ":runKtlintFormatOverKotlinScripts")
tasks.findByPath("processResources")
?.mustRunAfter(":runKtlintFormatOverKotlinScripts")
Proper fix will be available in the next release
Alternative workaround. It handles any source sets and any project structure. Apply it on every project that applies plugin
org.jlleitschuh.gradle.ktlint:project.tasks.withType(org.jlleitschuh.gradle.ktlint.tasks.GenerateReportsTask).configureEach { dependsOn project.tasks.named('runKtlintFormatOverKotlinScripts') }
Please note this has an unfortunate side effect/bug: It causes other task overlap conflicts in Gradle 7 as it will run the formatting task even though only org.jlleitschuh.gradle.ktlint.tasks.KtLintCheckTasks are requested, such as runKtlintCheckOverMainSourceSet
+1
Following and hoping for a fix.
Proper fix will be available in the next release
It's been a while. Is there something we can help with @Tapchicoma?
I hope It helps (Workaround)
afterEvaluate { [ "processResources", "ktlintMainSourceSetFormat", "runKtlintFormatOverMainSourceSet", "ktlintTestSourceSetFormat", "runKtlintFormatOverTestSourceSet", "compileKotlin", "ktlintKotlinScriptFormat", "runKtlintFormatOverKotlinScripts" ].forEach { name -> tasks.named(name).configure { if ("runKtlintFormatOverKotlinScripts" != name) { dependsOn("runKtlintFormatOverKotlinScripts") } if (project.parent != null && project.parent?.name != rootProject.name) { dependsOn(":${project.parent?.name}:runKtlintFormatOverKotlinScripts") } } } }
I tried something similar for my project. I added dependsOn on all the warnings that were displayed in the output log but it ended up making my ktFormat task not work altogether.
ktlint 10.2.0 and Gradle 7.2 do not produce these warnings anymore.
Really? I still get them for ktlint 10.2.0 and Gradle 7.3.2.
Can you post the exact errors your getting?
- What went wrong: Execution failed for task ':loadKtlintReporters'.
Could not resolve all files for configuration ':ktlint'. Could not resolve org.jetbrains.kotlinx:kotlinx-serialization-json:1.1.0. Required by: project : > com.pinterest:ktlint:0.42.1 > com.pinterest.ktlint:ktlint-reporter-sarif:0.42.1 > io.github.detekt.sarif4k:sarif4k:0.0.1 > Cannot choose between the following variants of org.jetbrains.kotlinx:kotlinx-serialization-json:1.1.0:
This is the error I am getting on running ./gradlew ktlintCheck
any updates on this?
@kritikapandey-jupiter looks like you're running into #553
This issue seems to have been solved, other errors posted were unrelated.