I’ve been using Gradle 2.5 for a multi-project C++ build, and want to run some of the executables created by my build as an additional task within the build. With 2.5, the following approach worked:
binaries.withType(NativeExecutableBinarySpec) { spec ->
spec.tasks.matching { task -> task.name.startsWith( ‘install’ ) }.each { installTask ->
// Create an Exec task instance to actually run the exe (and DLLs)
// collected together by the install task
}
}
However, in Gradle 2.6 and later, this no longer works - no ‘install*’ tasks are found by the matching filter. If I instead use
binaries.withType(NativeExecutableBinarySpec) { spec ->
project.tasks.matching{ task -> task.name.startsWith( ‘install’ ) }.whenTaskAdded{ … }
}
then I find the tasks, but my closure executes before the ‘executable’ property is set, so I get a null pointer exception when trying to identify the exe to actually run in the Exec task.
What has changed here, and how should I change my build script to work with Gradle 2.6 and newer?