org.gradle.platform.base.ComponentSpecContainer Java Examples

The following examples show how to use org.gradle.platform.base.ComponentSpecContainer. 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
Source File: JvmComponentPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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
Source File: NativeComponentModelPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 #3
Source File: JvmComponentPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 #4
Source File: NativeComponentModelPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 #5
Source File: ProjectLibraryBinaryLocator.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public DomainObjectSet<NativeLibraryBinary> getBinaries(NativeLibraryRequirement requirement) {
    Project project = findProject(requirement);
    ComponentSpecContainer componentSpecContainer = project.getExtensions().findByType(ComponentSpecContainer.class);
    if (componentSpecContainer == null) {
        throw new LibraryResolveException(String.format("Project does not have a libraries container: '%s'", project.getPath()));
    }
    DomainObjectSet<NativeBinarySpec> projectBinaries = componentSpecContainer.withType(NativeLibrarySpec.class).getByName(requirement.getLibraryName()).getNativeBinaries();
    DomainObjectSet<NativeLibraryBinary> binaries = new DefaultDomainObjectSet<NativeLibraryBinary>(NativeLibraryBinary.class);
    // TODO:DAZ Convert, don't cast
    for (NativeBinarySpec nativeBinarySpec : projectBinaries) {
        binaries.add((NativeLibraryBinary) nativeBinarySpec);
    }
    return binaries;
}
 
Example #6
Source File: ComponentReport.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@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 #7
Source File: BaseComponentModelPlugin.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
public void createAndroidComponents(
        ComponentSpecContainer androidSpecs,
        ServiceRegistry serviceRegistry, AndroidConfig androidExtension,
        com.android.build.gradle.AndroidConfig adaptedModel,
        @Path("android.buildTypes") ModelMap<BuildType> buildTypes,
        @Path("android.productFlavors") ModelMap<ProductFlavor> productFlavors,
        @Path("android.signingConfigs") ModelMap<SigningConfig> signingConfigs,
        VariantFactory variantFactory,
        TaskManager taskManager,
        Project project,
        AndroidBuilder androidBuilder,
        SdkHandler sdkHandler,
        ExtraModelInfo extraModelInfo,
        @Path("isApplication") Boolean isApplication) {
    Instantiator instantiator = serviceRegistry.get(Instantiator.class);

    // check if the target has been set.
    TargetInfo targetInfo = androidBuilder.getTargetInfo();
    if (targetInfo == null) {
        sdkHandler.initTarget(androidExtension.getCompileSdkVersion(),
                androidExtension.getBuildToolsRevision(),
                androidExtension.getLibraryRequests(), androidBuilder);
    }

    VariantManager variantManager = new VariantManager(project, androidBuilder,
            adaptedModel, variantFactory, taskManager, instantiator);

    for (BuildType buildType : buildTypes.values()) {
        variantManager.addBuildType(new BuildTypeAdaptor(buildType));
    }

    for (ProductFlavor productFlavor : productFlavors.values()) {
        variantManager.addProductFlavor(new ProductFlavorAdaptor(productFlavor));
    }

    DefaultAndroidComponentSpec spec =
            (DefaultAndroidComponentSpec) androidSpecs.get(COMPONENT_NAME);
    spec.setExtension(androidExtension);
    spec.setVariantManager(variantManager);
}
 
Example #8
Source File: ProjectLibraryBinaryLocator.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public DomainObjectSet<NativeLibraryBinary> getBinaries(NativeLibraryRequirement requirement) {
    Project project = findProject(requirement);
    ComponentSpecContainer componentSpecContainer = project.getExtensions().findByType(ComponentSpecContainer.class);
    if (componentSpecContainer == null) {
        throw new LibraryResolveException(String.format("Project does not have a libraries container: '%s'", project.getPath()));
    }
    DomainObjectSet<NativeBinarySpec> projectBinaries = componentSpecContainer.withType(NativeLibrarySpec.class).getByName(requirement.getLibraryName()).getNativeBinaries();
    DomainObjectSet<NativeLibraryBinary> binaries = new DefaultDomainObjectSet<NativeLibraryBinary>(NativeLibraryBinary.class);
    // TODO:DAZ Convert, don't cast
    for (NativeBinarySpec nativeBinarySpec : projectBinaries) {
        binaries.add((NativeLibraryBinary) nativeBinarySpec);
    }
    return binaries;
}
 
Example #9
Source File: ComponentReport.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@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 #10
Source File: JvmComponentPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Model
NamedDomainObjectCollection<JvmLibrarySpec> jvmLibraries(ComponentSpecContainer components) {
    return components.withType(JvmLibrarySpec.class);
}
 
Example #11
Source File: NativeComponentModelPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Model
NamedDomainObjectSet<NativeComponentSpec> nativeComponents(ComponentSpecContainer components) {
    return components.withType(NativeComponentSpec.class);
}
 
Example #12
Source File: JvmComponentPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Model
NamedDomainObjectCollection<JvmLibrarySpec> jvmLibraries(ComponentSpecContainer components) {
    return components.withType(JvmLibrarySpec.class);
}
 
Example #13
Source File: NativeComponentModelPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Model
NamedDomainObjectSet<NativeComponentSpec> nativeComponents(ComponentSpecContainer components) {
    return components.withType(NativeComponentSpec.class);
}