Package org.gradle.api.tasks

Examples of org.gradle.api.tasks.SourceSet


                sourceSet.setCompileClasspath(project.getConfigurations().getByName(COMPILE_CONFIGURATION_NAME));
                sourceSet.setRuntimeClasspath(sourceSet.getClasses().plus(project.getConfigurations().getByName(
                        RUNTIME_CONFIGURATION_NAME)));
            }
        });
        SourceSet main = pluginConvention.getSourceSets().add(SourceSet.MAIN_SOURCE_SET_NAME);

        SourceSet test = pluginConvention.getSourceSets().add(SourceSet.TEST_SOURCE_SET_NAME);
        test.setCompileClasspath(project.files(main.getClasses(), project.getConfigurations().getByName(
                TEST_COMPILE_CONFIGURATION_NAME)));
        test.setRuntimeClasspath(project.files(test.getClasses(), main.getClasses(),
                project.getConfigurations().getByName(TEST_RUNTIME_CONFIGURATION_NAME)));
    }
View Full Code Here


    }

    private void configureJavaDoc(final JavaPluginConvention pluginConvention) {
        Project project = pluginConvention.getProject();

        SourceSet mainSourceSet = pluginConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
        Javadoc javadoc = project.getTasks().add(JAVADOC_TASK_NAME, Javadoc.class);
        javadoc.setDescription("Generates the javadoc for the main source code.");
        javadoc.setGroup(JavaBasePlugin.DOCUMENTATION_GROUP);
        javadoc.setClasspath(mainSourceSet.getClasses().plus(mainSourceSet.getCompileClasspath()));
        javadoc.setSource(mainSourceSet.getAllJava());
        addDependsOnTaskInOtherProjects(javadoc, true, JAVADOC_TASK_NAME, COMPILE_CONFIGURATION_NAME);
    }
View Full Code Here

public class DefaultSourceSetContainerTest {
    private final DefaultSourceSetContainer container = new DefaultSourceSetContainer(null, null, new AsmBackedClassGenerator());

    @Test
    public void createsASourceSet() {
        SourceSet set = container.create("main");
        assertThat(set, instanceOf(DefaultSourceSet.class));
        assertThat(set, instanceOf(IConventionAware.class));
        assertThat(set.getName(), equalTo("main"));
    }
View Full Code Here

        // from the resources dirs
        {
            JavaPluginConvention javaConv = (JavaPluginConvention) project.getConvention().getPlugins().get("java");

            SourceSet main = javaConv.getSourceSets().getByName("main");
            SourceSet api = javaConv.getSourceSets().getByName("api");

            for (File at : main.getResources().getFiles())
            {
                if (at.getName().toLowerCase().endsWith("_at.cfg"))
                {
                    project.getLogger().lifecycle("Found AccessTransformer in main resources: " + at.getName());
                    binDeobf.addTransformer(at);
                    decompDeobf.addTransformer(at);
                }
            }

            for (File at : api.getResources().getFiles())
            {
                if (at.getName().toLowerCase().endsWith("_at.cfg"))
                {
                    project.getLogger().lifecycle("Found AccessTransformer in api resources: " + at.getName());
                    binDeobf.addTransformer(at);
View Full Code Here

    protected void configureCompilation()
    {
        // get conventions
        JavaPluginConvention javaConv = (JavaPluginConvention) project.getConvention().getPlugins().get("java");

        SourceSet main = javaConv.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
        SourceSet test = javaConv.getSourceSets().getByName(SourceSet.TEST_SOURCE_SET_NAME);
        SourceSet api = javaConv.getSourceSets().create("api");

        // set the Source
        javaConv.setSourceCompatibility("1.6");
        javaConv.setTargetCompatibility("1.6");

        main.setCompileClasspath(main.getCompileClasspath().plus(api.getOutput()));
        test.setCompileClasspath(test.getCompileClasspath().plus(api.getOutput()));

        project.getConfigurations().getByName("apiCompile").extendsFrom(project.getConfigurations().getByName("compile"));
        project.getConfigurations().getByName("testCompile").extendsFrom(project.getConfigurations().getByName("apiCompile"));
    }
View Full Code Here

    }
   
    private final void createSourceCopyTasks()
    {
        JavaPluginConvention javaConv = (JavaPluginConvention) project.getConvention().getPlugins().get("java");
        SourceSet main = javaConv.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);

        // do the special source moving...
        SourceCopyTask task;

        // main
        {
            DelayedFile dir = delayedFile(SOURCES_DIR + "/java");
           
            task = makeTask("sourceMainJava", SourceCopyTask.class);
            task.setSource(main.getJava());
            task.setOutput(dir);

            JavaCompile compile = (JavaCompile) project.getTasks().getByName(main.getCompileJavaTaskName());
            compile.dependsOn("sourceMainJava");
            compile.setSource(dir);
        }

        // scala!!!
        if (project.getPlugins().hasPlugin("scala"))
        {
            ScalaSourceSet set = (ScalaSourceSet) new DslObject(main).getConvention().getPlugins().get("scala");
            DelayedFile dir = delayedFile(SOURCES_DIR + "/scala");

            task = makeTask("sourceMainScala", SourceCopyTask.class);
            task.setSource(set.getScala());
            task.setOutput(dir);

            ScalaCompile compile = (ScalaCompile) project.getTasks().getByName(main.getCompileTaskName("scala"));
            compile.dependsOn("sourceMainScala");
            compile.setSource(dir);
        }

        // groovy!!!
        if (project.getPlugins().hasPlugin("groovy"))
        {
            GroovySourceSet set = (GroovySourceSet) new DslObject(main).getConvention().getPlugins().get("groovy");
            DelayedFile dir = delayedFile(SOURCES_DIR + "/groovy");

            task = makeTask("sourceMainGroovy", SourceCopyTask.class);
            task.setSource(set.getGroovy());
            task.setOutput(dir);

            GroovyCompile compile = (GroovyCompile) project.getTasks().getByName(main.getCompileTaskName("groovy"));
            compile.dependsOn("sourceMainGroovy");
            compile.setSource(dir);
        }
    }
View Full Code Here

      mainClass = (String) runTask.property("main");
    }

    if (mainClass == null) {
      // Search
      SourceSet mainSourceSet = SourceSets.findMainSourceSet(project);
      if (mainSourceSet != null) {
        project.getLogger().debug(
            "Looking for main in: "
                + mainSourceSet.getOutput().getClassesDir());
        try {
          mainClass = MainClassFinder.findSingleMainClass(mainSourceSet
              .getOutput().getClassesDir());
          project.getLogger().info("Computed main class: " + mainClass);
        }
        catch (IOException ex) {
          throw new IllegalStateException("Cannot find main class", ex);
View Full Code Here

*/
public class BootRunTask extends JavaExec {

  @Override
  public void exec() {
    SourceSet mainSourceSet = SourceSets.findMainSourceSet(getProject());
    final File outputDir = (mainSourceSet == null ? null : mainSourceSet.getOutput()
        .getResourcesDir());
    final Set<File> resources = new LinkedHashSet<File>();
    if (mainSourceSet != null) {
      resources.addAll(mainSourceSet.getResources().getSrcDirs());
    }
    List<File> classPath = new ArrayList<File>(getClasspath().getFiles());
    classPath.addAll(0, resources);
    getLogger().info("Adding classpath: " + resources);
    setClasspath(new SimpleFileCollection(classPath));
View Full Code Here

        project.getPlugins().withType(JavaPlugin.class, new Action<JavaPlugin>() {
            public void execute(JavaPlugin javaPlugin) {
                JavaPluginConvention javaPluginConvention = new DslObject(project).getConvention().getPlugin(JavaPluginConvention.class);

                SourceSet main = javaPluginConvention.getSourceSets().getAt("main");
                List<File> sourceDirectories = nonEmptyOrNull(Iterables.filter(main.getAllSource().getSrcDirs(), FILE_EXISTS));
                properties.put("sonar.sources" , sourceDirectories);
                SourceSet test = javaPluginConvention.getSourceSets().getAt("test");
                List<File> testDirectories = nonEmptyOrNull(Iterables.filter(test.getAllSource().getSrcDirs(), FILE_EXISTS));
                properties.put("sonar.tests", testDirectories);

                properties.put("sonar.binaries", nonEmptyOrNull(Iterables.filter(main.getRuntimeClasspath(), IS_DIRECTORY)));
                properties.put("sonar.libraries", getLibraries(main));
View Full Code Here

public class DefaultSourceSetContainerTest {
    private final DefaultSourceSetContainer container = new DefaultSourceSetContainer(null, null, new DirectInstantiator());

    @Test
    public void createsASourceSet() {
        SourceSet set = container.create("main");
        assertThat(set, instanceOf(DefaultSourceSet.class));
        assertThat(set.getName(), equalTo("main"));
    }
View Full Code Here

TOP

Related Classes of org.gradle.api.tasks.SourceSet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.