How can one add a dependency to one of the native compile tasks? For example, taking the samples/cpp as a starting point, I’d like to add the “clean” task as a dependency on compileHelloSharedLibraryHelloCpp.
compileHelloSharedLibraryHelloCpp.dependsOn clean
complains with
Could not find property ‘compileHelloSharedLibraryHelloCpp’ on root project ‘cpp’.
The native language and new publishing plugins both use the new configuration model, which means the syntax to configure their model elements is a bit different. For the most part, you simply need put this type of configuration within a ‘model {…}’ block. Take a look at the latest release notes for more info.
model {
tasks.compileHelloSharedLibraryHelloCpp {
dependsOn clean
}
}
Also, is there a specific reason why you need to perform a clean prior to your compile task? Incremental build support should make this unnecessary.
There’s a nicer way to do code generation with a native project: declare an additional source set with a ‘generatedBy’ property. The ‘native-binaries/idl’ sample gives an example:
The ‘idlOutput’ source set takes it’s configuration from ‘generator’ task, which must have a ‘sourceDir’ property and may have an optional ‘headerDir’ property.
Alternatively, you can wire in an arbitrary task for a source set as demonstrated in this integration test.