Enable caching of native image building and test tasks (#409)

Enable caching for the native image building task and improves the caching effectiveness of some of the test tasks in the project.
This commit is contained in:
Stefano Baghino
2024-04-18 17:28:56 +02:00
committed by GitHub
parent 31917d1556
commit 81bfdb7cbd
4 changed files with 16 additions and 14 deletions

View File

@@ -32,5 +32,5 @@ dependencies {
tasks.test { tasks.test {
inputs.files(fileTree("modules").matching { inputs.files(fileTree("modules").matching {
include("**/pages/*.adoc") include("**/pages/*.adoc")
}) }).withPropertyName("asciiDocFiles").withPathSensitivity(PathSensitivity.RELATIVE)
} }

View File

@@ -138,9 +138,11 @@ fun Exec.configureExecutable(isEnabled: Boolean, outputFile: Provider<RegularFil
enabled = isEnabled enabled = isEnabled
dependsOn(":installGraalVm") dependsOn(":installGraalVm")
inputs.files(sourceSets.main.map { it.output }) inputs.files(sourceSets.main.map { it.output }).withPropertyName("mainSourceSets").withPathSensitivity(PathSensitivity.RELATIVE)
inputs.files(configurations.runtimeClasspath) inputs.files(configurations.runtimeClasspath).withPropertyName("runtimeClasspath").withNormalizer(ClasspathNormalizer::class)
inputs.files(file(buildInfo.graalVm.baseDir).resolve("bin/native-image")).withPropertyName("graalVmNativeImage").withPathSensitivity(PathSensitivity.ABSOLUTE)
outputs.file(outputFile) outputs.file(outputFile)
outputs.cacheIf { true }
workingDir(outputFile.map { it.asFile.parentFile }) workingDir(outputFile.map { it.asFile.parentFile })
executable = "${buildInfo.graalVm.baseDir}/bin/native-image" executable = "${buildInfo.graalVm.baseDir}/bin/native-image"

View File

@@ -154,9 +154,9 @@ tasks.compileKotlin {
} }
tasks.test { tasks.test {
inputs.dir("src/test/files/LanguageSnippetTests/input") inputs.dir("src/test/files/LanguageSnippetTests/input").withPropertyName("languageSnippetTestsInput").withPathSensitivity(PathSensitivity.RELATIVE)
inputs.dir("src/test/files/LanguageSnippetTests/input-helper") inputs.dir("src/test/files/LanguageSnippetTests/input-helper").withPropertyName("languageSnippetTestsInputHelper").withPathSensitivity(PathSensitivity.RELATIVE)
inputs.dir("src/test/files/LanguageSnippetTests/output") inputs.dir("src/test/files/LanguageSnippetTests/output").withPropertyName("languageSnippetTestsOutput").withPathSensitivity(PathSensitivity.RELATIVE)
useJUnitPlatform { useJUnitPlatform {
excludeEngines("MacAmd64LanguageSnippetTestsEngine") excludeEngines("MacAmd64LanguageSnippetTestsEngine")
@@ -168,9 +168,9 @@ tasks.test {
} }
val testJavaExecutable by tasks.registering(Test::class) { val testJavaExecutable by tasks.registering(Test::class) {
inputs.dir("src/test/files/LanguageSnippetTests/input") inputs.dir("src/test/files/LanguageSnippetTests/input").withPropertyName("languageSnippetTestsInput").withPathSensitivity(PathSensitivity.RELATIVE)
inputs.dir("src/test/files/LanguageSnippetTests/input-helper") inputs.dir("src/test/files/LanguageSnippetTests/input-helper").withPropertyName("languageSnippetTestsInputHelper").withPathSensitivity(PathSensitivity.RELATIVE)
inputs.dir("src/test/files/LanguageSnippetTests/output") inputs.dir("src/test/files/LanguageSnippetTests/output").withPropertyName("languageSnippetTestsOutput").withPathSensitivity(PathSensitivity.RELATIVE)
testClassesDirs = files(tasks.test.get().testClassesDirs) testClassesDirs = files(tasks.test.get().testClassesDirs)
classpath = classpath =
@@ -196,9 +196,9 @@ val testMacExecutableAmd64 by tasks.registering(Test::class) {
enabled = buildInfo.os.isMacOsX && buildInfo.graalVm.isGraal22 enabled = buildInfo.os.isMacOsX && buildInfo.graalVm.isGraal22
dependsOn(":pkl-cli:macExecutableAmd64") dependsOn(":pkl-cli:macExecutableAmd64")
inputs.dir("src/test/files/LanguageSnippetTests/input") inputs.dir("src/test/files/LanguageSnippetTests/input").withPropertyName("languageSnippetTestsInput").withPathSensitivity(PathSensitivity.RELATIVE)
inputs.dir("src/test/files/LanguageSnippetTests/input-helper") inputs.dir("src/test/files/LanguageSnippetTests/input-helper").withPropertyName("languageSnippetTestsInputHelper").withPathSensitivity(PathSensitivity.RELATIVE)
inputs.dir("src/test/files/LanguageSnippetTests/output") inputs.dir("src/test/files/LanguageSnippetTests/output").withPropertyName("languageSnippetTestsOutput").withPathSensitivity(PathSensitivity.RELATIVE)
testClassesDirs = files(tasks.test.get().testClassesDirs) testClassesDirs = files(tasks.test.get().testClassesDirs)
classpath = tasks.test.get().classpath classpath = tasks.test.get().classpath

View File

@@ -14,6 +14,6 @@ dependencies {
} }
tasks.test { tasks.test {
inputs.dir("src/test/files/SnippetTests/input") inputs.dir("src/test/files/SnippetTests/input").withPropertyName("snippetTestsInput").withPathSensitivity(PathSensitivity.RELATIVE)
inputs.dir("src/test/files/SnippetTests/output") inputs.dir("src/test/files/SnippetTests/output").withPropertyName("snippetTestsOutput").withPathSensitivity(PathSensitivity.RELATIVE)
} }