JNI build with NativeLibrarySpec fails

I am attempting to build a JNI library using the NativeLibrarySpec using gradle 2.7.

gradlew tasks fails with the following:

Could not determine the dependencies of task ‘:compileFooSharedLibraryFooCpp’.

What is the work around?

Most examples appear to use an earlier version of gradle and manually set up a dependency within the scope of the model: eg

tasks.compileNativeSharedLibraryNativeCpp { dependsOn generateHeader }

However it appears that with newer gradle versions, the task doesnt exist within the scope of the model at execution time.