Skip to content

Commit 2235aeb

Browse files
committed
Fix jarFileTest cache relocatability
The jarFileTest task sets `systemProperty("jarFile", absolutePath)` which embeds an absolute path as a task input, making the task not cache-relocatable across different project locations. Fix by: - Using `inputs.files(shadowJar).withPathSensitivity(RELATIVE)` instead of the bare `file()` call (which doesn't register a proper input) - Passing the jar path as a relative path to the system property The test (AbstractJarFileTest) uses `Paths.get(System.getProperty("jarFile"))` which resolves relative paths against the working directory (project dir), so the test works identically with both absolute and relative paths.
1 parent 0bb0b2b commit 2235aeb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

core/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ task jarFileTest(type: Test) {
3434
testClassesDirs = sourceSets.jarFileTest.output.classesDirs
3535
classpath = sourceSets.jarFileTest.runtimeClasspath
3636

37-
file(shadowJar.outputs.files.singleFile) // input for correct caching
38-
systemProperty("jarFile", shadowJar.outputs.files.singleFile)
37+
inputs.files(shadowJar).withPathSensitivity(PathSensitivity.RELATIVE)
38+
systemProperty("jarFile", project.projectDir.toPath().relativize(shadowJar.outputs.files.singleFile.toPath()).toString())
3939

4040
dependsOn(shadowJar)
4141
}

0 commit comments

Comments
 (0)