org.gradle.platform.base.internal.DefaultComponentSpecIdentifier Java Examples

The following examples show how to use org.gradle.platform.base.internal.DefaultComponentSpecIdentifier. 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: 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 #3
Source File: ComponentTypeRuleDefinitionHandler.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #4
Source File: CUnitPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #5
Source File: JavaBasePlugin.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
private BridgedBinaries configureSourceSetDefaults(final JavaPluginConvention pluginConvention) {
    final Project project = pluginConvention.getProject();
    final List<ClassDirectoryBinarySpecInternal> binaries = Lists.newArrayList();
    pluginConvention.getSourceSets().all(new Action<SourceSet>() {
        public void execute(final SourceSet sourceSet) {
            ConventionMapping outputConventionMapping = ((IConventionAware) sourceSet.getOutput()).getConventionMapping();

            ConfigurationContainer configurations = project.getConfigurations();

            defineConfigurationsForSourceSet(sourceSet, configurations);
            definePathsForSourceSet(sourceSet, outputConventionMapping, project);

            createProcessResourcesTaskForBinary(sourceSet, sourceSet.getResources(), project);
            createCompileJavaTaskForBinary(sourceSet, sourceSet.getJava(), project);
            createBinaryLifecycleTask(sourceSet, project);

            DefaultComponentSpecIdentifier binaryId = new DefaultComponentSpecIdentifier(project.getPath(), sourceSet.getName());
            ClassDirectoryBinarySpecInternal binary = instantiator.newInstance(DefaultClassDirectoryBinarySpec.class, binaryId, sourceSet, javaToolChain, DefaultJavaPlatform.current(), instantiator, taskFactory);

            Classpath compileClasspath = new SourceSetCompileClasspath(sourceSet);
            DefaultJavaSourceSet javaSourceSet = instantiator.newInstance(DefaultJavaSourceSet.class, binaryId.child("java"), sourceSet.getJava(), compileClasspath);
            JvmResourceSet resourceSet = instantiator.newInstance(DefaultJvmResourceSet.class, binaryId.child("resources"), sourceSet.getResources());

            binary.addSourceSet(javaSourceSet);
            binary.addSourceSet(resourceSet);

            attachTasksToBinary(binary, sourceSet, project);
            binaries.add(binary);
        }
    });
    return new BridgedBinaries(binaries);
}
 
Example #6
Source File: ComponentTypeRuleDefinitionHandler.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #7
Source File: CUnitPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #8
Source File: NativeLibrarySpecFactory.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public NativeLibrarySpec create(String name) {
    ComponentSpecIdentifier id = new DefaultComponentSpecIdentifier(project.getPath(), name);
    return instantiator.newInstance(DefaultNativeLibrarySpec.class, id, sources.maybeCreate(name));
}
 
Example #9
Source File: NativeExecutableSpecFactory.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public NativeExecutableSpec create(String name) {
    ComponentSpecIdentifier id = new DefaultComponentSpecIdentifier(project.getPath(), name);
    return instantiator.newInstance(DefaultNativeExecutableSpec.class, id, sources.maybeCreate(name));
}
 
Example #10
Source File: NativeLibrarySpecFactory.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public NativeLibrarySpec create(String name) {
    ComponentSpecIdentifier id = new DefaultComponentSpecIdentifier(project.getPath(), name);
    return instantiator.newInstance(DefaultNativeLibrarySpec.class, id, sources.maybeCreate(name));
}
 
Example #11
Source File: NativeExecutableSpecFactory.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public NativeExecutableSpec create(String name) {
    ComponentSpecIdentifier id = new DefaultComponentSpecIdentifier(project.getPath(), name);
    return instantiator.newInstance(DefaultNativeExecutableSpec.class, id, sources.maybeCreate(name));
}