Java Code Examples for org.gradle.language.base.ProjectSourceSet

The following examples show how to use org.gradle.language.base.ProjectSourceSet. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public void apply(final Project project) {
    project.getPlugins().apply(ComponentModelBasePlugin.class);

    ComponentSpecContainer componentSpecs = project.getExtensions().getByType(ComponentSpecContainer.class);

    final ProjectSourceSet sources = project.getExtensions().getByType(ProjectSourceSet.class);
    componentSpecs.registerFactory(JvmLibrarySpec.class, new NamedDomainObjectFactory<JvmLibrarySpec>() {
        public JvmLibrarySpec create(String name) {
            ComponentSpecIdentifier id = new DefaultComponentSpecIdentifier(project.getPath(), name);
            return new DefaultJvmLibrarySpec(id, sources.maybeCreate(name));
        }
    });

    final NamedDomainObjectContainer<JvmLibrarySpec> jvmLibraries = componentSpecs.containerWithType(JvmLibrarySpec.class);
    project.getExtensions().create("jvm", DefaultJvmComponentExtension.class, jvmLibraries);
}
 
Example 2
public void apply(final ProjectInternal project) {
    project.getPlugins().apply(LanguageBasePlugin.class);

    LanguageRegistry languageRegistry = project.getExtensions().create("languages", DefaultLanguageRegistry.class);
    ProjectSourceSet sources = project.getExtensions().getByType(ProjectSourceSet.class);

    DefaultComponentSpecContainer components = project.getExtensions().create("componentSpecs", DefaultComponentSpecContainer.class, instantiator);
    modelRegistry.create(
            ModelCreators.of(ModelReference.of("componentSpecs", DefaultComponentSpecContainer.class), components)
                    .simpleDescriptor("Project.<init>.componentSpecs()")
                    .withProjection(new PolymorphicDomainObjectContainerModelProjection<DefaultComponentSpecContainer, ComponentSpec>(components, ComponentSpec.class))
                    .build()
                    );

    // TODO:DAZ Convert to model rules
    createLanguageSourceSets(sources, components, languageRegistry, project.getFileResolver());
}
 
Example 3
public void apply(final ProjectInternal project) {
    project.getPlugins().apply(ComponentModelBasePlugin.class);

    ProjectSourceSet sources = project.getExtensions().getByType(ProjectSourceSet.class);
    ComponentSpecContainer components = project.getExtensions().getByType(ComponentSpecContainer.class);
    components.registerFactory(NativeExecutableSpec.class, new NativeExecutableSpecFactory(instantiator, sources, project));
    NamedDomainObjectContainer<NativeExecutableSpec> nativeExecutables = components.containerWithType(NativeExecutableSpec.class);

    components.registerFactory(NativeLibrarySpec.class, new NativeLibrarySpecFactory(instantiator, sources, project));
    NamedDomainObjectContainer<NativeLibrarySpec> nativeLibraries = components.containerWithType(NativeLibrarySpec.class);

    project.getExtensions().create("nativeRuntime", DefaultNativeComponentExtension.class, nativeExecutables, nativeLibraries);

    // TODO:DAZ Remove these: should not pollute the global namespace
    project.getExtensions().add("nativeComponents", components.withType(NativeComponentSpec.class));
    project.getExtensions().add("executables", nativeExecutables);
    project.getExtensions().add("libraries", nativeLibraries);
}
 
Example 4
public void execute(ProjectInternal project) {
    ProjectSourceSet projectSourceSet = project.getExtensions().getByType(ProjectSourceSet.class);
    for (FunctionalSourceSet functionalSourceSet : projectSourceSet) {
        for (LanguageSourceSet languageSourceSet : functionalSourceSet) {
            // Only apply default locations when none explicitly configured
            if (languageSourceSet.getSource().getSrcDirs().isEmpty()) {
                languageSourceSet.getSource().srcDir(String.format("src/%s/%s", functionalSourceSet.getName(), languageSourceSet.getName()));
            }
        }
        for (HeaderExportingSourceSet headerSourceSet : functionalSourceSet.withType(HeaderExportingSourceSet.class)) {
            // Only apply default locations when none explicitly configured
            if (headerSourceSet.getExportedHeaders().getSrcDirs().isEmpty()) {
                headerSourceSet.getExportedHeaders().srcDir(String.format("src/%s/headers", functionalSourceSet.getName()));
            }

            headerSourceSet.getImplicitHeaders().setSrcDirs(headerSourceSet.getSource().getSrcDirs());
            headerSourceSet.getImplicitHeaders().include("**/*.h");
        }
    }
}
 
Example 5
public void apply(final Project project) {
    project.getPlugins().apply(ComponentModelBasePlugin.class);

    ComponentSpecContainer componentSpecs = project.getExtensions().getByType(ComponentSpecContainer.class);

    final ProjectSourceSet sources = project.getExtensions().getByType(ProjectSourceSet.class);
    componentSpecs.registerFactory(JvmLibrarySpec.class, new NamedDomainObjectFactory<JvmLibrarySpec>() {
        public JvmLibrarySpec create(String name) {
            ComponentSpecIdentifier id = new DefaultComponentSpecIdentifier(project.getPath(), name);
            return new DefaultJvmLibrarySpec(id, sources.maybeCreate(name));
        }
    });

    final NamedDomainObjectContainer<JvmLibrarySpec> jvmLibraries = componentSpecs.containerWithType(JvmLibrarySpec.class);
    project.getExtensions().create("jvm", DefaultJvmComponentExtension.class, jvmLibraries);
}
 
Example 6
public void apply(final ProjectInternal project) {
    project.getPlugins().apply(LanguageBasePlugin.class);

    LanguageRegistry languageRegistry = project.getExtensions().create("languages", DefaultLanguageRegistry.class);
    ProjectSourceSet sources = project.getExtensions().getByType(ProjectSourceSet.class);

    DefaultComponentSpecContainer components = project.getExtensions().create("componentSpecs", DefaultComponentSpecContainer.class, instantiator);
    modelRegistry.create(
            ModelCreators.of(ModelReference.of("componentSpecs", DefaultComponentSpecContainer.class), components)
                    .simpleDescriptor("Project.<init>.componentSpecs()")
                    .withProjection(new PolymorphicDomainObjectContainerModelProjection<DefaultComponentSpecContainer, ComponentSpec>(components, ComponentSpec.class))
                    .build()
                    );

    // TODO:DAZ Convert to model rules
    createLanguageSourceSets(sources, components, languageRegistry, project.getFileResolver());
}
 
Example 7
public void apply(final ProjectInternal project) {
    project.getPlugins().apply(ComponentModelBasePlugin.class);

    ProjectSourceSet sources = project.getExtensions().getByType(ProjectSourceSet.class);
    ComponentSpecContainer components = project.getExtensions().getByType(ComponentSpecContainer.class);
    components.registerFactory(NativeExecutableSpec.class, new NativeExecutableSpecFactory(instantiator, sources, project));
    NamedDomainObjectContainer<NativeExecutableSpec> nativeExecutables = components.containerWithType(NativeExecutableSpec.class);

    components.registerFactory(NativeLibrarySpec.class, new NativeLibrarySpecFactory(instantiator, sources, project));
    NamedDomainObjectContainer<NativeLibrarySpec> nativeLibraries = components.containerWithType(NativeLibrarySpec.class);

    project.getExtensions().create("nativeRuntime", DefaultNativeComponentExtension.class, nativeExecutables, nativeLibraries);

    // TODO:DAZ Remove these: should not pollute the global namespace
    project.getExtensions().add("nativeComponents", components.withType(NativeComponentSpec.class));
    project.getExtensions().add("executables", nativeExecutables);
    project.getExtensions().add("libraries", nativeLibraries);
}
 
Example 8
public void execute(ProjectInternal project) {
    ProjectSourceSet projectSourceSet = project.getExtensions().getByType(ProjectSourceSet.class);
    for (FunctionalSourceSet functionalSourceSet : projectSourceSet) {
        for (LanguageSourceSet languageSourceSet : functionalSourceSet) {
            // Only apply default locations when none explicitly configured
            if (languageSourceSet.getSource().getSrcDirs().isEmpty()) {
                languageSourceSet.getSource().srcDir(String.format("src/%s/%s", functionalSourceSet.getName(), languageSourceSet.getName()));
            }
        }
        for (HeaderExportingSourceSet headerSourceSet : functionalSourceSet.withType(HeaderExportingSourceSet.class)) {
            // Only apply default locations when none explicitly configured
            if (headerSourceSet.getExportedHeaders().getSrcDirs().isEmpty()) {
                headerSourceSet.getExportedHeaders().srcDir(String.format("src/%s/headers", functionalSourceSet.getName()));
            }

            headerSourceSet.getImplicitHeaders().setSrcDirs(headerSourceSet.getSource().getSrcDirs());
            headerSourceSet.getImplicitHeaders().include("**/*.h");
        }
    }
}
 
Example 9
private <T extends ComponentSpec, I extends BaseComponentSpec> void doRegister(final ModelType<T> type, final ModelType<I> implementation, final ProjectSourceSet projectSourceSet, ComponentSpecContainer componentSpecs, final ProjectIdentifier projectIdentifier) {
    componentSpecs.registerFactory(type.getConcreteClass(), new NamedDomainObjectFactory<T>() {
        public T create(String name) {
            FunctionalSourceSet componentSourceSet = projectSourceSet.maybeCreate(name);
            ComponentSpecIdentifier id = new DefaultComponentSpecIdentifier(projectIdentifier.getPath(), name);

            // safe because we implicitly know that U extends V, but can't express this in the type system
            @SuppressWarnings("unchecked")
            T created = (T) BaseComponentSpec.create(implementation.getConcreteClass(), id, componentSourceSet, instantiator);

            return created;
        }
    });
}
 
Example 10
private void createLanguageSourceSets(final ProjectSourceSet sources, final ComponentSpecContainer components, final LanguageRegistry languageRegistry, final FileResolver fileResolver) {
    languageRegistry.all(new Action<LanguageRegistration<?>>() {
        public void execute(final LanguageRegistration<?> languageRegistration) {
            registerLanguageSourceSetFactory(languageRegistration, sources, fileResolver);
            createDefaultSourceSetForComponents(languageRegistration, components);
        }
    });
}
 
Example 11
private <U extends LanguageSourceSet> void registerLanguageSourceSetFactory(final LanguageRegistration<U> languageRegistration, ProjectSourceSet sources, final FileResolver fileResolver) {
    sources.all(new Action<FunctionalSourceSet>() {
        public void execute(final FunctionalSourceSet functionalSourceSet) {
            NamedDomainObjectFactory<U> namedDomainObjectFactory = new NamedDomainObjectFactory<U>() {
                public U create(String name) {
                    Class<? extends U> sourceSetImplementation = languageRegistration.getSourceSetImplementation();
                    return instantiator.newInstance(sourceSetImplementation, name, functionalSourceSet, fileResolver);
                }
            };
            functionalSourceSet.registerFactory(languageRegistration.getSourceSetType(), namedDomainObjectFactory);
        }
    });
}
 
Example 12
@Finalize
// Needs to run after NativeComponentModelPlugin.Rules.configureGeneratedSourceSets()
void applyDefaultSourceConventions(ProjectSourceSet sources) {
    for (FunctionalSourceSet functionalSourceSet : sources) {
        for (LanguageSourceSet languageSourceSet : functionalSourceSet) {
            // Only apply default locations when none explicitly configured
            if (languageSourceSet.getSource().getSrcDirs().isEmpty()) {
                languageSourceSet.getSource().srcDir(String.format("src/%s/%s", functionalSourceSet.getName(), languageSourceSet.getName()));
            }
        }
    }
}
 
Example 13
@Mutate
public void createCUnitTestSuitePerComponent(TestSuiteContainer testSuites, NamedDomainObjectSet<NativeComponentSpec> components, ProjectSourceSet projectSourceSet, ServiceRegistry serviceRegistry) {
    Instantiator instantiator = serviceRegistry.get(Instantiator.class);
    for (NativeComponentSpec component : components) {
        testSuites.add(createCUnitTestSuite(component, instantiator, projectSourceSet));
    }
}
 
Example 14
private CUnitTestSuiteSpec createCUnitTestSuite(final NativeComponentSpec testedComponent, Instantiator instantiator, ProjectSourceSet projectSourceSet) {
    String suiteName = String.format("%sTest", testedComponent.getName());
    String path = testedComponent.getProjectPath();
    ComponentSpecIdentifier id = new DefaultComponentSpecIdentifier(path, suiteName);
    FunctionalSourceSet testSuiteSourceSet = projectSourceSet.maybeCreate(suiteName);
    return instantiator.newInstance(DefaultCUnitTestSuiteSpec.class, id, testedComponent, testSuiteSourceSet);
}
 
Example 15
@Mutate
public void configureCUnitTestSuiteSources(ProjectSourceSet projectSourceSet, TestSuiteContainer testSuites, @Path("buildDir") File buildDir) {

    for (final CUnitTestSuiteSpec suite : testSuites.withType(CUnitTestSuiteSpec.class)) {
        FunctionalSourceSet suiteSourceSet = ((ComponentSpecInternal) suite).getMainSource();
        CSourceSet launcherSources = suiteSourceSet.maybeCreate(CUNIT_LAUNCHER_SOURCE_SET, CSourceSet.class);
        File baseDir = new File(buildDir, String.format("src/%s/cunitLauncher", suite.getName()));
        launcherSources.getSource().srcDir(new File(baseDir, "c"));
        launcherSources.getExportedHeaders().srcDir(new File(baseDir, "headers"));
        CSourceSet testSources = suiteSourceSet.maybeCreate("c", CSourceSet.class);
        testSources.lib(launcherSources);
    }
}
 
Example 16
@Mutate
public void createCUnitLauncherTasks(TaskContainer tasks, TestSuiteContainer testSuites, ProjectSourceSet sources) {
    for (final CUnitTestSuiteSpec suite : testSuites.withType(CUnitTestSuiteSpec.class)) {

        String taskName = suite.getName() + "CUnitLauncher";
        GenerateCUnitLauncher skeletonTask = tasks.create(taskName, GenerateCUnitLauncher.class);

        CSourceSet launcherSources = findLaucherSources(suite);
        skeletonTask.setSourceDir(launcherSources.getSource().getSrcDirs().iterator().next());
        skeletonTask.setHeaderDir(launcherSources.getExportedHeaders().getSrcDirs().iterator().next());
        launcherSources.builtBy(skeletonTask);
    }
}
 
Example 17
@Mutate
void configureGeneratedSourceSets(ProjectSourceSet sources) {
    for (FunctionalSourceSet functionalSourceSet : sources) {
        for (LanguageSourceSetInternal languageSourceSet : functionalSourceSet.withType(LanguageSourceSetInternal.class)) {
            Task generatorTask = languageSourceSet.getGeneratorTask();
            if (generatorTask != null) {
                languageSourceSet.builtBy(generatorTask);
                maybeSetSourceDir(languageSourceSet.getSource(), generatorTask, "sourceDir");
                if (languageSourceSet instanceof HeaderExportingSourceSet) {
                    maybeSetSourceDir(((HeaderExportingSourceSet) languageSourceSet).getExportedHeaders(), generatorTask, "headerDir");
                }
            }
        }
    }
}
 
Example 18
@Finalize
public void applyHeaderSourceSetConventions(ProjectSourceSet sources) {
    for (FunctionalSourceSet functionalSourceSet : sources) {
        for (HeaderExportingSourceSet headerSourceSet : functionalSourceSet.withType(HeaderExportingSourceSet.class)) {
            // Only apply default locations when none explicitly configured
            if (headerSourceSet.getExportedHeaders().getSrcDirs().isEmpty()) {
                headerSourceSet.getExportedHeaders().srcDir(String.format("src/%s/headers", functionalSourceSet.getName()));
            }

            headerSourceSet.getImplicitHeaders().setSrcDirs(headerSourceSet.getSource().getSrcDirs());
            headerSourceSet.getImplicitHeaders().include("**/*.h");
        }
    }
}
 
Example 19
@TaskAction
public void report() {
    Project project = getProject();

    StyledTextOutput textOutput = getTextOutputFactory().create(ComponentReport.class);
    ComponentReportRenderer renderer = new ComponentReportRenderer(getFileResolver());
    renderer.setOutput(textOutput);

    renderer.startProject(project);

    Collection<ComponentSpec> components = new ArrayList<ComponentSpec>();
    ComponentSpecContainer componentSpecs = project.getExtensions().findByType(ComponentSpecContainer.class);
    if (componentSpecs != null) {
        components.addAll(componentSpecs);
    }

    try {
        TestSuiteContainer testSuites = getModelRegistry().get(ModelPath.path("testSuites"), ModelType.of(TestSuiteContainer.class));
        components.addAll(testSuites);
    } catch (IllegalStateException e) {
        // TODO - need a better contract here
        // Ignore for now
    }

    renderer.renderComponents(components);

    ProjectSourceSet sourceSets = project.getExtensions().findByType(ProjectSourceSet.class);
    if (sourceSets != null) {
        renderer.renderSourceSets(sourceSets);
    }
    BinaryContainer binaries = project.getExtensions().findByType(BinaryContainer.class);
    if (binaries != null) {
        renderer.renderBinaries(binaries);
    }

    renderer.completeProject(project);
    renderer.complete();
}
 
Example 20
public void execute(ProjectInternal project) {
    ProjectSourceSet projectSourceSet = project.getExtensions().getByType(ProjectSourceSet.class);
    for (FunctionalSourceSet functionalSourceSet : projectSourceSet) {
        for (LanguageSourceSetInternal languageSourceSet : functionalSourceSet.withType(LanguageSourceSetInternal.class)) {
            Task generatorTask = languageSourceSet.getGeneratorTask();
            if (generatorTask != null) {
                languageSourceSet.builtBy(generatorTask);
                maybeSetSourceDir(languageSourceSet.getSource(), generatorTask, "sourceDir");
                if (languageSourceSet instanceof HeaderExportingSourceSet) {
                    maybeSetSourceDir(((HeaderExportingSourceSet) languageSourceSet).getExportedHeaders(), generatorTask, "headerDir");
                }
            }
        }
    }
}
 
Example 21
public void apply(final Project target) {
    target.getPlugins().apply(JvmLanguagePlugin.class);

    BinaryContainer jvmBinaryContainer = target.getExtensions().getByType(BinaryContainer.class);
    jvmBinaryContainer.withType(ClassDirectoryBinary.class).all(new Action<ClassDirectoryBinary>() {
        public void execute(final ClassDirectoryBinary binary) {
            final BinaryNamingScheme namingScheme = ((BinaryInternal) binary).getNamingScheme();
            binary.getSource().withType(JavaSourceSet.class).all(new Action<JavaSourceSet>() {
                public void execute(JavaSourceSet javaSourceSet) {
                    // TODO: handle case where binary has multiple JavaSourceSet's
                    JavaCompile compileTask = target.getTasks().create(namingScheme.getTaskName("compile", "java"), JavaCompile.class);
                    configureCompileTask(compileTask, javaSourceSet, binary);
                    binary.builtBy(compileTask);
                }
            });
        }
    });

    ProjectSourceSet projectSourceSet = target.getExtensions().getByType(DefaultProjectSourceSet.class);
    projectSourceSet.all(new Action<FunctionalSourceSet>() {
        public void execute(final FunctionalSourceSet functionalSourceSet) {
            functionalSourceSet.registerFactory(JavaSourceSet.class, new NamedDomainObjectFactory<JavaSourceSet>() {
                public JavaSourceSet create(String name) {
                    return instantiator.newInstance(DefaultJavaSourceSet.class, name,
                            instantiator.newInstance(DefaultSourceDirectorySet.class, name, fileResolver),
                            instantiator.newInstance(DefaultClasspath.class, fileResolver,
                                    target.getTasks()), functionalSourceSet);
                }
            });
        }
    });
}
 
Example 22
/**
 * Create all source sets for each AndroidBinary.
 */
@Mutate
public void createVariantSourceSet(
        @Path("android.sources") final AndroidComponentModelSourceSet sources,
        @Path("android.buildTypes") final ModelMap<BuildType> buildTypes,
        @Path("android.productFlavors") ModelMap<ProductFlavor> flavors,
        List<ProductFlavorCombo<ProductFlavor>> flavorGroups, ProjectSourceSet projectSourceSet,
        LanguageRegistry languageRegistry) {
    sources.setProjectSourceSet(projectSourceSet);
    for (LanguageRegistration languageRegistration : languageRegistry) {
        sources.registerLanguage(languageRegistration);
    }

    // Create main source set.
    sources.create("main");

    for (BuildType buildType : buildTypes.values()) {
        sources.maybeCreate(buildType.getName());

        for (ProductFlavorCombo group : flavorGroups) {
            sources.maybeCreate(group.getName());
            if (!group.getFlavorList().isEmpty()) {
                sources.maybeCreate(
                        group.getName() + StringHelper.capitalize(buildType.getName()));
            }

        }

    }
    if (flavorGroups.size() != flavors.size()) {
        // If flavorGroups and flavors are the same size, there is at most 1 flavor
        // dimension.  So we don't need to reconfigure the source sets for flavorGroups.
        for (ProductFlavor flavor : flavors.values()) {
            sources.maybeCreate(flavor.getName());
        }
    }
}
 
Example 23
private <T extends ComponentSpec, I extends BaseComponentSpec> void doRegister(final ModelType<T> type, final ModelType<I> implementation, final ProjectSourceSet projectSourceSet, ComponentSpecContainer componentSpecs, final ProjectIdentifier projectIdentifier) {
    componentSpecs.registerFactory(type.getConcreteClass(), new NamedDomainObjectFactory<T>() {
        public T create(String name) {
            FunctionalSourceSet componentSourceSet = projectSourceSet.maybeCreate(name);
            ComponentSpecIdentifier id = new DefaultComponentSpecIdentifier(projectIdentifier.getPath(), name);

            // safe because we implicitly know that U extends V, but can't express this in the type system
            @SuppressWarnings("unchecked")
            T created = (T) BaseComponentSpec.create(implementation.getConcreteClass(), id, componentSourceSet, instantiator);

            return created;
        }
    });
}
 
Example 24
private void createLanguageSourceSets(final ProjectSourceSet sources, final ComponentSpecContainer components, final LanguageRegistry languageRegistry, final FileResolver fileResolver) {
    languageRegistry.all(new Action<LanguageRegistration<?>>() {
        public void execute(final LanguageRegistration<?> languageRegistration) {
            registerLanguageSourceSetFactory(languageRegistration, sources, fileResolver);
            createDefaultSourceSetForComponents(languageRegistration, components);
        }
    });
}
 
Example 25
private <U extends LanguageSourceSet> void registerLanguageSourceSetFactory(final LanguageRegistration<U> languageRegistration, ProjectSourceSet sources, final FileResolver fileResolver) {
    sources.all(new Action<FunctionalSourceSet>() {
        public void execute(final FunctionalSourceSet functionalSourceSet) {
            NamedDomainObjectFactory<U> namedDomainObjectFactory = new NamedDomainObjectFactory<U>() {
                public U create(String name) {
                    Class<? extends U> sourceSetImplementation = languageRegistration.getSourceSetImplementation();
                    return instantiator.newInstance(sourceSetImplementation, name, functionalSourceSet, fileResolver);
                }
            };
            functionalSourceSet.registerFactory(languageRegistration.getSourceSetType(), namedDomainObjectFactory);
        }
    });
}
 
Example 26
@Finalize
// Needs to run after NativeComponentModelPlugin.Rules.configureGeneratedSourceSets()
void applyDefaultSourceConventions(ProjectSourceSet sources) {
    for (FunctionalSourceSet functionalSourceSet : sources) {
        for (LanguageSourceSet languageSourceSet : functionalSourceSet) {
            // Only apply default locations when none explicitly configured
            if (languageSourceSet.getSource().getSrcDirs().isEmpty()) {
                languageSourceSet.getSource().srcDir(String.format("src/%s/%s", functionalSourceSet.getName(), languageSourceSet.getName()));
            }
        }
    }
}
 
Example 27
@Mutate
public void createCUnitTestSuitePerComponent(TestSuiteContainer testSuites, NamedDomainObjectSet<NativeComponentSpec> components, ProjectSourceSet projectSourceSet, ServiceRegistry serviceRegistry) {
    Instantiator instantiator = serviceRegistry.get(Instantiator.class);
    for (NativeComponentSpec component : components) {
        testSuites.add(createCUnitTestSuite(component, instantiator, projectSourceSet));
    }
}
 
Example 28
private CUnitTestSuiteSpec createCUnitTestSuite(final NativeComponentSpec testedComponent, Instantiator instantiator, ProjectSourceSet projectSourceSet) {
    String suiteName = String.format("%sTest", testedComponent.getName());
    String path = testedComponent.getProjectPath();
    ComponentSpecIdentifier id = new DefaultComponentSpecIdentifier(path, suiteName);
    FunctionalSourceSet testSuiteSourceSet = projectSourceSet.maybeCreate(suiteName);
    return instantiator.newInstance(DefaultCUnitTestSuiteSpec.class, id, testedComponent, testSuiteSourceSet);
}
 
Example 29
@Mutate
public void configureCUnitTestSuiteSources(ProjectSourceSet projectSourceSet, TestSuiteContainer testSuites, @Path("buildDir") File buildDir) {

    for (final CUnitTestSuiteSpec suite : testSuites.withType(CUnitTestSuiteSpec.class)) {
        FunctionalSourceSet suiteSourceSet = ((ComponentSpecInternal) suite).getMainSource();
        CSourceSet launcherSources = suiteSourceSet.maybeCreate(CUNIT_LAUNCHER_SOURCE_SET, CSourceSet.class);
        File baseDir = new File(buildDir, String.format("src/%s/cunitLauncher", suite.getName()));
        launcherSources.getSource().srcDir(new File(baseDir, "c"));
        launcherSources.getExportedHeaders().srcDir(new File(baseDir, "headers"));
        CSourceSet testSources = suiteSourceSet.maybeCreate("c", CSourceSet.class);
        testSources.lib(launcherSources);
    }
}
 
Example 30
@Mutate
public void createCUnitLauncherTasks(TaskContainer tasks, TestSuiteContainer testSuites, ProjectSourceSet sources) {
    for (final CUnitTestSuiteSpec suite : testSuites.withType(CUnitTestSuiteSpec.class)) {

        String taskName = suite.getName() + "CUnitLauncher";
        GenerateCUnitLauncher skeletonTask = tasks.create(taskName, GenerateCUnitLauncher.class);

        CSourceSet launcherSources = findLaucherSources(suite);
        skeletonTask.setSourceDir(launcherSources.getSource().getSrcDirs().iterator().next());
        skeletonTask.setHeaderDir(launcherSources.getExportedHeaders().getSrcDirs().iterator().next());
        launcherSources.builtBy(skeletonTask);
    }
}