Skip to content

Commit

Permalink
Read project rootdir within task creation rather than within task action
Browse files Browse the repository at this point in the history
  • Loading branch information
rschattauer authored and JLLeitschuh committed Nov 6, 2023
1 parent 2f3a679 commit 0f75ad1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
## [Unreleased]

- update latest version text file manually [#716](https://github.com/JLLeitschuh/ktlint-gradle/pull/716)
- Fix configuration cache for relative paths [#722](https://github.com/JLLeitschuh/ktlint-gradle/pull/722)

## [11.6.1] - 2023-10-10

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ abstract class GenerateReportsTask @Inject constructor(
@get:Optional
internal abstract val baseline: RegularFileProperty

/**
* Reading a project's rootDir within a task's action is not allowed for configuration
* cache, so read it eagerly on task initialization.
* see: https://docs.gradle.org/current/userguide/configuration_cache.html#config_cache
*/
private val rootDir: File = project.rootDir

init {
// Workaround for https://github.com/gradle/gradle/issues/2919
onlyIf {
Expand Down Expand Up @@ -142,7 +149,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)
}
}
}
Expand Down

0 comments on commit 0f75ad1

Please sign in to comment.