Search in sources :

Example 1 with DefaultJavaSourceSet

use of org.gradle.api.internal.java.DefaultJavaSourceSet in project gradle by gradle.

the class JavaBasePlugin method configureSourceSetDefaults.

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);
}
Also used : ClassDirectoryBinarySpecInternal(org.gradle.api.internal.jvm.ClassDirectoryBinarySpecInternal) ConventionMapping(org.gradle.api.internal.ConventionMapping) SourceSetCompileClasspath(org.gradle.api.internal.tasks.SourceSetCompileClasspath) JvmResourceSet(org.gradle.language.jvm.JvmResourceSet) DefaultJvmResourceSet(org.gradle.api.internal.java.DefaultJvmResourceSet) Project(org.gradle.api.Project) ProjectSourceSet(org.gradle.language.base.ProjectSourceSet) DefaultJavaSourceSet(org.gradle.api.internal.java.DefaultJavaSourceSet) SourceSet(org.gradle.api.tasks.SourceSet) DefaultJvmResourceSet(org.gradle.api.internal.java.DefaultJvmResourceSet) DefaultJavaSourceSet(org.gradle.api.internal.java.DefaultJavaSourceSet) ConfigurationContainer(org.gradle.api.artifacts.ConfigurationContainer) DefaultClassDirectoryBinarySpec(org.gradle.api.internal.jvm.DefaultClassDirectoryBinarySpec) Classpath(org.gradle.jvm.Classpath) SourceSetCompileClasspath(org.gradle.api.internal.tasks.SourceSetCompileClasspath) DefaultComponentSpecIdentifier(org.gradle.platform.base.internal.DefaultComponentSpecIdentifier)

Aggregations

Project (org.gradle.api.Project)1 ConfigurationContainer (org.gradle.api.artifacts.ConfigurationContainer)1 ConventionMapping (org.gradle.api.internal.ConventionMapping)1 DefaultJavaSourceSet (org.gradle.api.internal.java.DefaultJavaSourceSet)1 DefaultJvmResourceSet (org.gradle.api.internal.java.DefaultJvmResourceSet)1 ClassDirectoryBinarySpecInternal (org.gradle.api.internal.jvm.ClassDirectoryBinarySpecInternal)1 DefaultClassDirectoryBinarySpec (org.gradle.api.internal.jvm.DefaultClassDirectoryBinarySpec)1 SourceSetCompileClasspath (org.gradle.api.internal.tasks.SourceSetCompileClasspath)1 SourceSet (org.gradle.api.tasks.SourceSet)1 Classpath (org.gradle.jvm.Classpath)1 ProjectSourceSet (org.gradle.language.base.ProjectSourceSet)1 JvmResourceSet (org.gradle.language.jvm.JvmResourceSet)1 DefaultComponentSpecIdentifier (org.gradle.platform.base.internal.DefaultComponentSpecIdentifier)1