I have a Gradle (7.5) build script that includes this task:
task eecs_transpile_to_xml(
type: JavaExec,
dependsOn: ["eecs_sources", "build_transpiler"],
description: "Transpile the EECS Java to XML"
) {
inputs.files fileTree(dir: "${buildDir}/src/eecs")
outputs.files fileTree(dir: "${buildDir}/ee_xmlout")
classpath = configurations.transpiler
mainClass = "ToXml"
args "-j:${buildDir}/src/eecs",
"-repo:${projectDir}",
"-xml:${buildDir}/ee_xmlout",
"-h:${projectDir}/src/main/java",
"-src:${projectDir}/src/main/java",
"-ee:${saxonVersion}",
"-icu4j:${icu4jJar}"
doFirst {
mkdir("${buildDir}/ee_xmlout")
}
}
The eecs_sources
task creates a bunch of files under ${buildDir}/src/eecs
. The build_transpiler
task compiles the ToXml
class and it’s related dependencies. On a MacOS box, this works fine. The eecs_sources
task runs, then the transpiler runs.
I’ve been working on some regression testing, running builds on different platforms and I’ve discovered that this doesn’t work on Linux. If I execute:
TERM=dumb ./gradlew --info clean eecs_transpile_to_xml
I get a trace that ends like this:
> Task :eecs_sources
Watching 548 directories to track changes
Caching disabled for task ':eecs_sources' because:
Build cache is disabled
Task ':eecs_sources' is not up-to-date because:
Output property 'destinationDir' file /Volumes/Saxonica/src/saxonica/saxondev/build/src/eecs has been removed.
Output property 'destinationDir' file /Volumes/Saxonica/src/saxonica/saxondev/build/src/eecs/com has been removed.
Output property 'destinationDir' file /Volumes/Saxonica/src/saxonica/saxondev/build/src/eecs/com/saxonica has been removed.
Watching 547 directories to track changes
Watching 633 directories to track changes
:eecs_sources (Thread[Execution worker Thread 4,5,main]) completed. Took 0.489 secs.
Resolve mutations for :eecs_transpile_to_xml (Thread[Execution worker,5,main]) started.
Resolve mutations for :eecs_transpile_to_xml (Thread[Execution worker,5,main]) completed. Took 0.0 secs.
:eecs_transpile_to_xml (Thread[Execution worker Thread 4,5,main]) started.
producer locations for task group 1 (Thread[Execution worker,5,main]) started.
producer locations for task group 1 (Thread[Execution worker,5,main]) completed. Took 0.0 secs.
> Task :eecs_transpile_to_xml UP-TO-DATE
file or directory '/Volumes/Saxonica/src/saxonica/saxondev/build/ee_xmlout', not found
Watching 634 directories to track changes
Caching disabled for task ':eecs_transpile_to_xml' because:
Build cache is disabled
Skipping task ':eecs_transpile_to_xml' as it is up-to-date.
:eecs_transpile_to_xml (Thread[Execution worker Thread 4,5,main]) completed. Took 0.001 secs.
BUILD SUCCESSFUL in 20s
19 actionable tasks: 14 executed, 5 up-to-date
Given that the output directory doesn’t exist and the input files have changed, why does Gradle report this task as up-to-date? Why is this behavior different on Linux and Mac?