There seems to be a bug at line 32 of file NativeBinaryRules.java [1]. The rule assume only one node will be of type File which maps to buildDir (the @Path is commented out). This is problematic when trying to follow the same pattern and have root element for reports directory and possibly more. The following code show the failure:
class Rules extends RuleSource {
@Model
File reportsDir(@Path("buildDir") File buildDir) {
return new File(buildDir, "reports")
}
}
apply plugin: Rules
apply plugin: "cpp"
model {
toolChains {
msvc(VisualCpp)
}
components {
main(NativeExecutableSpec)
}
}
Executing $ ./gradlew.bat :tasks
will cause the following exception:
> Exception thrown while executing model rule: NativeComponentModelPlugin.Rules#createBinaries(TargetedNativeComponentInterval, PlatformResolvers, BuildTypeContainer, FlavorContainer, ServiceRegistry) > named(executable, org.gradle.nativeplatform.internal.configure.NativeBinaryRules)
> There is a problem with model rule NativeBinaryRules#assignTools(NativeBinarySpec, NativeToolChainRegistryInternal, File).
> Type-only model reference of type java.io.File (parameter 3) is ambiguous as multiple model elements are available for this type:
- buildDir (created by: Project.<init>.buildDir())
- reportsDir (created by: Rules#reportsDir(File))
The gradle version we are using is 2.14.1 on a Windows operating system. They may be other rules coded like this one which would require grepping the codebase in order to find them and apply a fix.