[GRADLE-3523] Native binaries plugins prevent from registering root nodes of type File Created: 17/Aug/16  Updated: 18/Aug/16  Resolved: 18/Aug/16

Status: Resolved
Project: Gradle
Affects Version/s: 2.14.1, 3.0
Fix Version/s: 3.1-rc-1

Type: Bug
Reporter: Cédric Champeau (Inactive) Assignee: Paul Merlin
Resolution: Fixed Votes: 0


 Description   

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.

[1] https://github.com/gradle/gradle/blob/master/subprojects/platform-native/src/main/java/org/gradle/nativeplatform/internal/configure/NativeBinaryRules.java#L321


Generated at Wed Jun 30 12:51:01 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.