Search in sources :

Example 1 with ComponentSpecContainer

use of org.gradle.platform.base.ComponentSpecContainer in project gradle by gradle.

the class DependentComponentsUtils method getAllComponents.

public static Set<ComponentSpec> getAllComponents(ModelRegistry registry) {
    Set<ComponentSpec> components = Sets.newLinkedHashSet();
    ComponentSpecContainer componentSpecs = modelElement(registry, "components", ComponentSpecContainer.class);
    if (componentSpecs != null) {
        components.addAll(componentSpecs.values());
    }
    return components;
}
Also used : ComponentSpecContainer(org.gradle.platform.base.ComponentSpecContainer) ComponentSpec(org.gradle.platform.base.ComponentSpec)

Example 2 with ComponentSpecContainer

use of org.gradle.platform.base.ComponentSpecContainer in project gradle by gradle.

the class ProjectLibraryBinaryLocator method getBinaries.

// Converts the binaries of a project library into regular binary instances
@Nullable
@Override
public DomainObjectSet<NativeLibraryBinary> getBinaries(LibraryIdentifier libraryIdentifier) {
    ModelRegistry projectModel = projectModelResolver.resolveProjectModel(libraryIdentifier.getProjectPath());
    ComponentSpecContainer components = projectModel.find("components", ComponentSpecContainer.class);
    if (components == null) {
        return null;
    }
    String libraryName = libraryIdentifier.getLibraryName();
    NativeLibrarySpec library = components.withType(NativeLibrarySpec.class).get(libraryName);
    if (library == null) {
        return null;
    }
    ModelMap<NativeBinarySpec> projectBinaries = library.getBinaries().withType(NativeBinarySpec.class);
    DomainObjectSet<NativeLibraryBinary> binaries = new DefaultDomainObjectSet<NativeLibraryBinary>(NativeLibraryBinary.class);
    for (NativeBinarySpec nativeBinarySpec : projectBinaries.values()) {
        binaries.add((NativeLibraryBinary) nativeBinarySpec);
    }
    return binaries;
}
Also used : NativeLibraryBinary(org.gradle.nativeplatform.NativeLibraryBinary) ModelRegistry(org.gradle.model.internal.registry.ModelRegistry) NativeBinarySpec(org.gradle.nativeplatform.NativeBinarySpec) ComponentSpecContainer(org.gradle.platform.base.ComponentSpecContainer) NativeLibrarySpec(org.gradle.nativeplatform.NativeLibrarySpec) DefaultDomainObjectSet(org.gradle.api.internal.DefaultDomainObjectSet) Nullable(javax.annotation.Nullable)

Example 3 with ComponentSpecContainer

use of org.gradle.platform.base.ComponentSpecContainer in project gradle by gradle.

the class ComponentReport method report.

@TaskAction
public void report() {
    Project project = getProject();
    StyledTextOutput textOutput = getTextOutputFactory().create(ComponentReport.class);
    ComponentReportRenderer renderer = new ComponentReportRenderer(getFileResolver(), getBinaryRenderer());
    renderer.setOutput(textOutput);
    renderer.startProject(project);
    Collection<ComponentSpec> components = new ArrayList<ComponentSpec>();
    ComponentSpecContainer componentSpecs = modelElement("components", ComponentSpecContainer.class);
    if (componentSpecs != null) {
        components.addAll(componentSpecs.values());
    }
    ModelMap<ComponentSpec> testSuites = modelElement("testSuites", modelMap(ComponentSpec.class));
    if (testSuites != null) {
        components.addAll(testSuites.values());
    }
    renderer.renderComponents(components);
    ProjectSourceSet sourceSets = modelElement("sources", ProjectSourceSet.class);
    if (sourceSets != null) {
        renderer.renderSourceSets(sourceSets);
    }
    BinaryContainer binaries = modelElement("binaries", BinaryContainer.class);
    if (binaries != null) {
        renderer.renderBinaries(binaries.values());
    }
    renderer.completeProject(project);
    renderer.complete();
}
Also used : Project(org.gradle.api.Project) ProjectSourceSet(org.gradle.language.base.ProjectSourceSet) ComponentSpecContainer(org.gradle.platform.base.ComponentSpecContainer) ComponentReportRenderer(org.gradle.api.reporting.components.internal.ComponentReportRenderer) BinaryContainer(org.gradle.platform.base.BinaryContainer) ArrayList(java.util.ArrayList) StyledTextOutput(org.gradle.internal.logging.text.StyledTextOutput) ComponentSpec(org.gradle.platform.base.ComponentSpec) TaskAction(org.gradle.api.tasks.TaskAction)

Aggregations

ComponentSpecContainer (org.gradle.platform.base.ComponentSpecContainer)3 ComponentSpec (org.gradle.platform.base.ComponentSpec)2 ArrayList (java.util.ArrayList)1 Nullable (javax.annotation.Nullable)1 Project (org.gradle.api.Project)1 DefaultDomainObjectSet (org.gradle.api.internal.DefaultDomainObjectSet)1 ComponentReportRenderer (org.gradle.api.reporting.components.internal.ComponentReportRenderer)1 TaskAction (org.gradle.api.tasks.TaskAction)1 StyledTextOutput (org.gradle.internal.logging.text.StyledTextOutput)1 ProjectSourceSet (org.gradle.language.base.ProjectSourceSet)1 ModelRegistry (org.gradle.model.internal.registry.ModelRegistry)1 NativeBinarySpec (org.gradle.nativeplatform.NativeBinarySpec)1 NativeLibraryBinary (org.gradle.nativeplatform.NativeLibraryBinary)1 NativeLibrarySpec (org.gradle.nativeplatform.NativeLibrarySpec)1 BinaryContainer (org.gradle.platform.base.BinaryContainer)1