From 8d3121d4ca87c83776c69a3dfc2001ea89067689 Mon Sep 17 00:00:00 2001 From: Richard Schattauer Date: Mon, 30 Oct 2023 20:42:23 +0100 Subject: [PATCH] Read project rootdir within task creation rather than within task action --- .../jlleitschuh/gradle/ktlint/tasks/GenerateReportsTask.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/tasks/GenerateReportsTask.kt b/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/tasks/GenerateReportsTask.kt index 813eab7e..531b8ccc 100644 --- a/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/tasks/GenerateReportsTask.kt +++ b/plugin/src/main/kotlin/org/jlleitschuh/gradle/ktlint/tasks/GenerateReportsTask.kt @@ -90,6 +90,8 @@ abstract class GenerateReportsTask @Inject constructor( @get:Optional internal abstract val baseline: RegularFileProperty + private val rootDir: File = project.rootDir + init { // Workaround for https://github.com/gradle/gradle/issues/2919 onlyIf { @@ -142,7 +144,7 @@ abstract class GenerateReportsTask @Inject constructor( param.baseline.set(baseline) param.projectDirectory.set(projectLayout.projectDirectory) if (relative.get()) { - param.filePathsRelativeTo.set(project.rootDir) + param.filePathsRelativeTo.set(rootDir) } } }