We have a task that creates files that are the inputs for another task. Unfortunately, the configuration phase doesn’t see these files and mistakenly considers the other task up to date. How can I get the task that is dependent on these dynamically created files to build the first time?
A couple of other questions related to the C plugin are:
Is this the best way to make your build dependent on the cspiceStaticLibrary task?
How do you make the cpiceStaticLibrary task (which was dynamically created) dependent on other tasks?
Here’s a small example that doesn’t compile the C code the first time through:
// Create a file mice/src/cspice/foo.c with the content
//
#include <stdio.h>
//
foo() {printf("Hello, world!");}
// and then call "tar -czf mice.tar.gz mice"
apply plugin: 'c'
defaultTasks 'assemble'
sources {
cspice {
c {
source {
srcDir "$buildDir/mice/src/cspice"
include "**/*.c"
}
}
}
}
libraries {
cspice {
binaries.all {}
}
}
task extractTar(type: Exec) {
mkdir buildDir
inputs.file "mice.tar.Z"
outputs.dir "$buildDir/mice"
commandLine "tar", "-xf", "mice.tar.gz", "-C", buildDir
}
assemble.dependsOn extractTar
assemble.dependsOn "cspiceStaticLibrary"
------------------------------------------------------------
Gradle 1.11
------------------------------------------------------------
Build time:
2014-02-11 11:34:39 UTC
Build number: none
Revision:
a831fa866d46cbee94e61a09af15f9dd95987421
Groovy:
1.8.6
Ant:
Apache Ant(TM) version 1.9.2 compiled on July 8 2013
Ivy:
2.2.0
JVM:
1.7.0_51 (Oracle Corporation 24.51-b03)
OS:
Linux 2.6.32-431.11.2.el6.x86_64 amd64