I can’t add a “dependsOn” dependency to an existing task from the “cpp” plugin. The gradle build-file
apply plugin: ‘cpp’
task checkExpat(type: Exec) {
ignoreExitValue = true
standardOutput = new ByteArrayOutputStream()
commandLine ‘yum’, ‘info’, ‘expat-devel’
}
task ensureExpat(type: Exec, dependsOn: ‘checkExpat’) {
onlyIf { checkExpat.execResult.getExitValue() != 0 }
commandLine ‘yum’, ‘install’, ‘expat-devel’
}
sources {
lib {
c {
source { srcDirs = [“src/lib”] }
}
}
}
libraries {
udunits2 {
source sources.lib
}
}
udunits2SharedLibrary.dependsOn ensureExpat
results in the following:
~/udunits2: gradle dependencies
FAILURE: Build failed with an exception.
- Where:
Build file ‘/home/steve/udunits2/problem.gradle’ line: 23
- What went wrong:
A problem occurred evaluating root project ‘udunits2’.
Could not find property ‘udunits2SharedLibrary’ on root project ‘udunits2’.
- Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 1.852 secs
even though “udunits2SharedLibrary” is a valid task according to the output of ‘gradle tasks’