Hello,
I think I a missing something. I am trying to write a plugin using the new rule based configuration to process CxxTest files. I have added a custom language, component type and binaries which appear in the model report as expected. Here is the code.
@Managed
interface CxxTestSourceSet extends LanguageSourceSet {}
//class DefaultCxxTestSourceSet extends BaseLanguageSourceSet implements CxxTestSourceSet {}
@Managed
interface CxxTestComponent extends ComponentSpec {}
//class DefaultCxxTestComponent extends BaseComponentSpec implements CxxTestComponent {}
@Managed
interface CxxTestBinary extends BinarySpec {}
//class DefaultCxxTestBinary extends BaseBinarySpec implements CxxTestBinary {}
apply plugin: CxxTestPlugin
class CxxTestPlugin extends RuleSource {
@LanguageType
void register(LanguageTypeBuilder<CxxTestSourceSet> builder) {
builder.setLanguageName("cxxtest")
}
@ComponentType
void register(ComponentTypeBuilder<CxxTestComponent> builder) {
}
@BinaryType
void register(BinaryTypeBuilder<CxxTestBinary> builder) {
}
@ComponentBinaries
void createBinariesForCxxTestComponent(ModelMap<CxxTestBinary> binaries, CxxTestComponent component) {
binaries.create("${component.name}Binary", CxxTestBinary)
}
@BinaryTasks
void createCxxTestProcessingTasks(ModelMap<Task> tasks, final CxxTestBinary binary) {
// binary.inputs.withType(CxxTestSourceSet) { cxxTestSourceSet ->
// def taskName = binary.tasks.taskName("compile", cxxTestSourceSet.name)
tasks.create("${binary.name}Task1", DefaultTask) {
doLast {println "Do Something."}
}
// }
}
@Model
void testSuites(ModelMap<CxxTestComponent> testSuites){}
@Model
void cxxTest(CxxTest cxxTest) {
//conventions
cxxTest.executable = '/usr/bin/cxxtestgen'
}
}
model {
testSuites {
test1 (CxxTestComponent) {
sources {
mysource(CxxTestSourceSet) {
source {
srcDirs 'primitives/cxxtests'
include 'test_string_utils.h'
}
}
}
}
}
}
and here is the model report:
+ testSuites
| Type: org.gradle.model.ModelMap<CxxTestComponent>
| Creator: CxxTestPlugin#testSuites
| Rules:
? testSuites { ... } @ build.gradle.cxxtest line 319, column 3
+ test1
| Type: CxxTestComponent
| Creator: test1(CxxTestComponent) { ... } @ build.gradle.cxxtest line 320, column 5
| Rules:
? ComponentRules#addSourcesSetsToProjectSourceSet
? ComponentRules#applyDefaultSourceConventions
? ComponentRules#initializeSourceSets
? ComponentRules#inputRules
? CxxTestPlugin#createBinariesForCxxTestComponent
+ binaries
| Type: org.gradle.model.ModelMap<org.gradle.platform.base.BinarySpec>
| Creator: test1(CxxTestComponent) { ... } @ build.gradle.cxxtest line 320, column 5
| Rules:
? ComponentRules.AttachInputs#initializeBinarySourceSets
+ test1Binary
| Type: CxxTestBinary
| Creator: CxxTestPlugin#createBinariesForCxxTestComponent > create(test1Binary)
| Rules:
? BinaryBasePlugin.apply()
? ComponentRules.AttachInputs#initializeBinarySourceSets > withType()
? BaseBinaryRules#defineBuildLifecycleTask
? BaseBinaryRules#addSourceSetsOwnedByBinariesToTheirInputs
+ sources
| Type: org.gradle.model.ModelMap<org.gradle.language.base.LanguageSourceSet>
| Creator: CxxTestPlugin#createBinariesForCxxTestComponent > create(test1Binary)
+ tasks
| Type: org.gradle.platform.base.BinaryTasksCollection
| Value: []
| Creator: CxxTestPlugin#createBinariesForCxxTestComponent > create(test1Binary)
+ sources
| Type: org.gradle.model.ModelMap<org.gradle.language.base.LanguageSourceSet>
| Creator: test1(CxxTestComponent) { ... } @ build.gradle.cxxtest line 320, column 5
+ mysource
| Type: CxxTestSourceSet
| Value: CxxTestSourceSet 'test1:mysource'
| Creator: test1(CxxTestComponent) { ... } @ build.gradle.cxxtest line 320, column 5 > create(mysource)
| Rules:
? ComponentRules#addSourcesSetsToProjectSourceSet > afterEach()
? ComponentRules#applyDefaultSourceConventions > afterEach()
+ toolChains
| Type: org.gradle.nativeplatform.toolchain.internal.NativeToolChainRegistryInternal
| Value: [Tool chain 'catone_gcc' (GNU GCC), Tool chain 'x86_gcc' (GNU GCC)]
| Creator: NativeComponentModelPlugin.Rules#toolChains
| Rules:
? MicrosoftVisualCppPlugin.Rules#addToolChain
? GccCompilerPlugin.Rules#addToolChain
? ClangCompilerPlugin.Rules#addToolChain
? toolChains { ... } @ build.gradle.cxxtest line 62, column 3
? NativeComponentModelPlugin.Rules#createDefaultToolChain
My expectation was that I would get a task named test1BinaryTask1 and it would show up under
testSuites:test1:binaries:test1Binary:tasks
but I don’t see a task created at all. It seems like it isn’t finding any model elements with the type ‘CxxTestBinary’, but one does exist in the model. What am I missing?
Thanks,
Derek