Skip to content

Commit

Permalink
Fix lint warning & Could not read report path
Browse files Browse the repository at this point in the history
Replace buildDir with layout.buildDirectory.
This also seems to fix an (GradleException: Could not read path feature-X/build/reports/ktlint/main-format.txt) with project that have 200+ modules.
  • Loading branch information
marukami committed Dec 12, 2023
1 parent 243931c commit 80eac7d
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package org.jmailen.gradle.kotlinter
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.file.RegularFile
import org.gradle.api.provider.Provider
import org.gradle.api.tasks.TaskProvider
import org.jmailen.gradle.kotlinter.pluginapplier.AndroidSourceSetApplier
import org.jmailen.gradle.kotlinter.pluginapplier.KotlinSourceSetApplier
Expand All @@ -11,7 +13,6 @@ import org.jmailen.gradle.kotlinter.tasks.FormatTask
import org.jmailen.gradle.kotlinter.tasks.InstallPreCommitHookTask
import org.jmailen.gradle.kotlinter.tasks.InstallPrePushHookTask
import org.jmailen.gradle.kotlinter.tasks.LintTask
import java.io.File

class KotlinterPlugin : Plugin<Project> {

Expand Down Expand Up @@ -45,7 +46,7 @@ class KotlinterPlugin : Plugin<Project> {
lintTask.reports.set(
provider {
kotlinterExtension.reporters.associateWith { reporter ->
reportFile("$id-lint.${reporterFileExtension(reporter)}")
reportFile("$id-lint.${reporterFileExtension(reporter)}").get().asFile
}
},
)
Expand Down Expand Up @@ -99,4 +100,4 @@ class KotlinterPlugin : Plugin<Project> {
internal val String.id: String
get() = split(" ").first()

internal fun Project.reportFile(name: String): File = file("$buildDir/reports/ktlint/$name")
internal fun Project.reportFile(name: String): Provider<RegularFile> = layout.buildDirectory.file("reports/ktlint/$name")

0 comments on commit 80eac7d

Please sign in to comment.