Java Code Examples for org.gradle.language.jvm.JvmResourceSet

The following examples show how to use org.gradle.language.jvm.JvmResourceSet. 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 SourceTransformTaskConfig getTransformTask() {
    return new SourceTransformTaskConfig() {
        public String getTaskPrefix() {
            return "process";
        }

        public Class<? extends DefaultTask> getTaskType() {
            return ProcessResources.class;
        }

        public void configureTask(Task task, BinarySpec binary, LanguageSourceSet sourceSet) {
            ProcessResources resourcesTask = (ProcessResources) task;
            JvmResourceSet resourceSet = (JvmResourceSet) sourceSet;
            JvmBinarySpec jvmBinary = (JvmBinarySpec) binary;
            resourcesTask.from(resourceSet.getSource());
            resourcesTask.setDestinationDir(jvmBinary.getResourcesDir());
            jvmBinary.getTasks().getJar().dependsOn(resourcesTask);
        }
    };
}
 
Example 2
private void createProcessResourcesTaskForBinary(final ClassDirectoryBinarySpecInternal binary, final Project target) {
    final BinaryNamingScheme namingScheme = binary.getNamingScheme();
    binary.getSource().withType(JvmResourceSet.class).all(new Action<JvmResourceSet>() {
        public void execute(JvmResourceSet resourceSet) {
            Copy resourcesTask = target.getTasks().create(namingScheme.getTaskName("process", "resources"), ProcessResources.class);
            resourcesTask.setDescription(String.format("Processes %s.", resourceSet));
            new DslObject(resourcesTask).getConventionMapping().map("destinationDir", new Callable<File>() {
                public File call() throws Exception {
                    return binary.getResourcesDir();
                }
            });
            binary.getTasks().add(resourcesTask);
            binary.builtBy(resourcesTask);
            resourcesTask.from(resourceSet.getSource());
        }
    });
}
 
Example 3
public SourceTransformTaskConfig getTransformTask() {
    return new SourceTransformTaskConfig() {
        public String getTaskPrefix() {
            return "process";
        }

        public Class<? extends DefaultTask> getTaskType() {
            return ProcessResources.class;
        }

        public void configureTask(Task task, BinarySpec binary, LanguageSourceSet sourceSet) {
            ProcessResources resourcesTask = (ProcessResources) task;
            JvmResourceSet resourceSet = (JvmResourceSet) sourceSet;
            JvmBinarySpec jvmBinary = (JvmBinarySpec) binary;
            resourcesTask.from(resourceSet.getSource());
            resourcesTask.setDestinationDir(jvmBinary.getResourcesDir());
            jvmBinary.getTasks().getJar().dependsOn(resourcesTask);
        }
    };
}
 
Example 4
private void createProcessResourcesTaskForBinary(final ClassDirectoryBinarySpecInternal binary, final Project target) {
    final BinaryNamingScheme namingScheme = binary.getNamingScheme();
    binary.getSource().withType(JvmResourceSet.class).all(new Action<JvmResourceSet>() {
        public void execute(JvmResourceSet resourceSet) {
            Copy resourcesTask = target.getTasks().create(namingScheme.getTaskName("process", "resources"), ProcessResources.class);
            resourcesTask.setDescription(String.format("Processes %s.", resourceSet));
            new DslObject(resourcesTask).getConventionMapping().map("destinationDir", new Callable<File>() {
                public File call() throws Exception {
                    return binary.getResourcesDir();
                }
            });
            binary.getTasks().add(resourcesTask);
            binary.builtBy(resourcesTask);
            resourcesTask.from(resourceSet.getSource());
        }
    });
}
 
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
public Class<JvmResourceSet> getSourceSetType() {
    return JvmResourceSet.class;
}
 
Example 7
public Class<? extends JvmResourceSet> getSourceSetImplementation() {
    return DefaultJvmResourceSet.class;
}
 
Example 8
public Class<JvmResourceSet> getSourceSetType() {
    return JvmResourceSet.class;
}
 
Example 9
public Class<? extends JvmResourceSet> getSourceSetImplementation() {
    return DefaultJvmResourceSet.class;
}