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

The following examples show how to use org.gradle.platform.base.internal.DefaultComponentSpecIdentifier. 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 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
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
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 Project: javaide   Source File: JavaBasePlugin.java    License: 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
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
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
public NativeLibrarySpec create(String name) {
    ComponentSpecIdentifier id = new DefaultComponentSpecIdentifier(project.getPath(), name);
    return instantiator.newInstance(DefaultNativeLibrarySpec.class, id, sources.maybeCreate(name));
}
 
Example 9
public NativeExecutableSpec create(String name) {
    ComponentSpecIdentifier id = new DefaultComponentSpecIdentifier(project.getPath(), name);
    return instantiator.newInstance(DefaultNativeExecutableSpec.class, id, sources.maybeCreate(name));
}
 
Example 10
public NativeLibrarySpec create(String name) {
    ComponentSpecIdentifier id = new DefaultComponentSpecIdentifier(project.getPath(), name);
    return instantiator.newInstance(DefaultNativeLibrarySpec.class, id, sources.maybeCreate(name));
}
 
Example 11
public NativeExecutableSpec create(String name) {
    ComponentSpecIdentifier id = new DefaultComponentSpecIdentifier(project.getPath(), name);
    return instantiator.newInstance(DefaultNativeExecutableSpec.class, id, sources.maybeCreate(name));
}