Hi,
I’m playing around with the software model
@Managed
interface TheApp extends ApplicationSpec {}
@Managed
interface TheAppBinary extends ApplicationBinarySpec {}
class MyRules extends RuleSource{
@ComponentBinaries
void appBinaries(ModelMap<TheAppBinary> binaries, TheApp app) {
binaries.create(app.name) {}
}
}
apply plugin : MyRules
model {
components {
main(TheApp) {}
}
}
I get following error
> Exception thrown while executing model rule: MyRules#appBinaries > create(main)
> Cannot create a 'org.gradle.platform.base.ApplicationSpec' because this type is not known to components. Known types are: (None)
if I change from ApplicationBinarySpec to just BinarySpec it works. Maybe I got it wrong but I thought when I define a custom ApplicationSpec the binary part should be of ApplicationBinarySpec.
Done with 2.11-rc-1
In 2.11 you need to register both the component type (TheApp
) and binary type (TheAppBinary
). You do this using methods on the RuleSource
. Take a look at the customModel/componentType
sample in the Gradle distribution for an example of how to do this.
Ok I overlooked that, but after adding I get a similar error
@Managed
interface TheApp extends ApplicationSpec {}
@Managed
interface TheAppBinary extends ApplicationBinarySpec {}
class MyRules extends RuleSource{
@ComponentType
void register(ComponentTypeBuilder<TheApp> builder) {}
@BinaryType
void register(BinaryTypeBuilder<TheAppBinary> builder) {}
@ComponentBinaries
void appBinaries(ModelMap<TheAppBinary> binaries, TheApp app) {
binaries.create(app.name) {}
}
}
apply plugin : MyRules
model {
components {
main(TheApp) {}
}
}
Exception thrown while executing model rule: MyRules#appBinaries > create(main)
Cannot create a ‘org.gradle.platform.base.ApplicationSpec’ because this type is not known to components. Known types are: TheApp
Ok, this looks like a bug. As a workaround, you can have TheAppBinary
extend BinarySpec
instead of ApplicationBinarySpec
.
ok thanks, should I create an issue for that?