Search in sources :

Example 56 with SourceSet

use of org.gradle.api.tasks.SourceSet in project spring-boot by spring-projects.

the class SystemTestPlugin method createSourceSet.

private SourceSet createSourceSet(Project project) {
    SourceSetContainer sourceSets = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets();
    SourceSet systemTestSourceSet = sourceSets.create(SYSTEM_TEST_SOURCE_SET_NAME);
    SourceSet mainSourceSet = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
    systemTestSourceSet.setCompileClasspath(systemTestSourceSet.getCompileClasspath().plus(mainSourceSet.getOutput()));
    systemTestSourceSet.setRuntimeClasspath(systemTestSourceSet.getRuntimeClasspath().plus(mainSourceSet.getOutput()));
    return systemTestSourceSet;
}
Also used : SourceSet(org.gradle.api.tasks.SourceSet) JavaPluginExtension(org.gradle.api.plugins.JavaPluginExtension) SourceSetContainer(org.gradle.api.tasks.SourceSetContainer)

Example 57 with SourceSet

use of org.gradle.api.tasks.SourceSet in project spring-boot by spring-projects.

the class SystemTestPlugin method configureSystemTesting.

private void configureSystemTesting(Project project) {
    SourceSet systemTestSourceSet = createSourceSet(project);
    createTestTask(project, systemTestSourceSet);
    project.getPlugins().withType(EclipsePlugin.class, (eclipsePlugin) -> {
        EclipseModel eclipse = project.getExtensions().getByType(EclipseModel.class);
        eclipse.classpath((classpath) -> classpath.getPlusConfigurations().add(project.getConfigurations().getByName(systemTestSourceSet.getRuntimeClasspathConfigurationName())));
    });
}
Also used : SourceSet(org.gradle.api.tasks.SourceSet) EclipseModel(org.gradle.plugins.ide.eclipse.model.EclipseModel)

Example 58 with SourceSet

use of org.gradle.api.tasks.SourceSet in project spring-boot by spring-projects.

the class AutoConfigurationPlugin method apply.

@Override
public void apply(Project project) {
    project.getPlugins().apply(DeployedPlugin.class);
    project.getPlugins().withType(JavaPlugin.class, (javaPlugin) -> {
        project.getPlugins().apply(ConfigurationPropertiesPlugin.class);
        Configuration annotationProcessors = project.getConfigurations().getByName(JavaPlugin.ANNOTATION_PROCESSOR_CONFIGURATION_NAME);
        annotationProcessors.getDependencies().add(project.getDependencies().project(Collections.singletonMap("path", ":spring-boot-project:spring-boot-tools:spring-boot-autoconfigure-processor")));
        annotationProcessors.getDependencies().add(project.getDependencies().project(Collections.singletonMap("path", ":spring-boot-project:spring-boot-tools:spring-boot-configuration-processor")));
        project.getTasks().create("autoConfigurationMetadata", AutoConfigurationMetadata.class, (task) -> {
            SourceSet main = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
            task.setSourceSet(main);
            task.dependsOn(main.getClassesTaskName());
            task.setOutputFile(new File(project.getBuildDir(), "auto-configuration-metadata.properties"));
            project.getArtifacts().add(AutoConfigurationPlugin.AUTO_CONFIGURATION_METADATA_CONFIGURATION_NAME, project.provider((Callable<File>) task::getOutputFile), (artifact) -> artifact.builtBy(task));
        });
    });
}
Also used : SourceSet(org.gradle.api.tasks.SourceSet) Configuration(org.gradle.api.artifacts.Configuration) File(java.io.File) Callable(java.util.concurrent.Callable)

Example 59 with SourceSet

use of org.gradle.api.tasks.SourceSet in project spring-boot by spring-projects.

the class IntegrationTestPlugin method configureIntegrationTesting.

private void configureIntegrationTesting(Project project) {
    SourceSet intTestSourceSet = createSourceSet(project);
    Test intTest = createTestTask(project, intTestSourceSet);
    project.getTasks().getByName(LifecycleBasePlugin.CHECK_TASK_NAME).dependsOn(intTest);
    project.getPlugins().withType(EclipsePlugin.class, (eclipsePlugin) -> {
        EclipseModel eclipse = project.getExtensions().getByType(EclipseModel.class);
        eclipse.classpath((classpath) -> classpath.getPlusConfigurations().add(project.getConfigurations().getByName(intTestSourceSet.getRuntimeClasspathConfigurationName())));
    });
}
Also used : SourceSet(org.gradle.api.tasks.SourceSet) Test(org.gradle.api.tasks.testing.Test) EclipseModel(org.gradle.plugins.ide.eclipse.model.EclipseModel)

Example 60 with SourceSet

use of org.gradle.api.tasks.SourceSet in project spring-boot by spring-projects.

the class IntegrationTestPlugin method createSourceSet.

private SourceSet createSourceSet(Project project) {
    SourceSetContainer sourceSets = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets();
    SourceSet intTestSourceSet = sourceSets.create(INT_TEST_SOURCE_SET_NAME);
    SourceSet main = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
    intTestSourceSet.setCompileClasspath(intTestSourceSet.getCompileClasspath().plus(main.getOutput()));
    intTestSourceSet.setRuntimeClasspath(intTestSourceSet.getRuntimeClasspath().plus(main.getOutput()));
    return intTestSourceSet;
}
Also used : SourceSet(org.gradle.api.tasks.SourceSet) JavaPluginExtension(org.gradle.api.plugins.JavaPluginExtension) SourceSetContainer(org.gradle.api.tasks.SourceSetContainer)

Aggregations

SourceSet (org.gradle.api.tasks.SourceSet)76 File (java.io.File)34 SourceSetContainer (org.gradle.api.tasks.SourceSetContainer)31 Configuration (org.gradle.api.artifacts.Configuration)26 Project (org.gradle.api.Project)24 ConfigurationContainer (org.gradle.api.artifacts.ConfigurationContainer)23 Task (org.gradle.api.Task)18 List (java.util.List)17 JavaPluginConvention (org.gradle.api.plugins.JavaPluginConvention)17 JavaPlugin (org.gradle.api.plugins.JavaPlugin)16 JavaPluginExtension (org.gradle.api.plugins.JavaPluginExtension)16 JavaCompile (org.gradle.api.tasks.compile.JavaCompile)16 Plugin (org.gradle.api.Plugin)15 FileCollection (org.gradle.api.file.FileCollection)15 Action (org.gradle.api.Action)14 TaskProvider (org.gradle.api.tasks.TaskProvider)14 Set (java.util.Set)13 Jar (org.gradle.api.tasks.bundling.Jar)13 Collections (java.util.Collections)12 Collectors (java.util.stream.Collectors)12