use of org.gradle.api.tasks.SourceSet in project spring-boot by spring-projects.
the class BootRun method sourceResources.
/**
* Adds the {@link SourceDirectorySet#getSrcDirs() source directories} of the given
* {@code sourceSet's} {@link SourceSet#getResources() resources} to the start of the
* classpath in place of the {@link SourceSet#getOutput output's}
* {@link SourceSetOutput#getResourcesDir() resources directory}.
* @param sourceSet the source set
*/
public void sourceResources(SourceSet sourceSet) {
File resourcesDir = sourceSet.getOutput().getResourcesDir();
Set<File> srcDirs = sourceSet.getResources().getSrcDirs();
setClasspath(getProject().files(srcDirs, getClasspath()).filter((file) -> !file.equals(resourcesDir)));
}
use of org.gradle.api.tasks.SourceSet in project spring-boot by spring-projects.
the class JavaPluginAction method configureBootJarTask.
private TaskProvider<BootJar> configureBootJarTask(Project project) {
SourceSet mainSourceSet = javaPluginExtension(project).getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
Configuration developmentOnly = project.getConfigurations().getByName(SpringBootPlugin.DEVELOPMENT_ONLY_CONFIGURATION_NAME);
Configuration productionRuntimeClasspath = project.getConfigurations().getByName(SpringBootPlugin.PRODUCTION_RUNTIME_CLASSPATH_CONFIGURATION_NAME);
Callable<FileCollection> classpath = () -> mainSourceSet.getRuntimeClasspath().minus((developmentOnly.minus(productionRuntimeClasspath))).filter(new JarTypeFileSpec());
TaskProvider<ResolveMainClassName> resolveMainClassName = ResolveMainClassName.registerForTask(SpringBootPlugin.BOOT_JAR_TASK_NAME, project, classpath);
return project.getTasks().register(SpringBootPlugin.BOOT_JAR_TASK_NAME, BootJar.class, (bootJar) -> {
bootJar.setDescription("Assembles an executable jar archive containing the main classes and their dependencies.");
bootJar.setGroup(BasePlugin.BUILD_GROUP);
bootJar.classpath(classpath);
Provider<String> manifestStartClass = project.provider(() -> (String) bootJar.getManifest().getAttributes().get("Start-Class"));
bootJar.getMainClass().convention(resolveMainClassName.flatMap((resolver) -> manifestStartClass.isPresent() ? manifestStartClass : resolveMainClassName.get().readMainClassName()));
});
}
use of org.gradle.api.tasks.SourceSet in project gradle by gradle.
the class JavaPlugin method apply.
@Override
public void apply(final Project project) {
if (project.getPluginManager().hasPlugin("java-platform")) {
throw new IllegalStateException("The \"java\" or \"java-library\" plugin cannot be applied together with the \"java-platform\" plugin. " + "A project is either a platform or a library but cannot be both at the same time.");
}
final ProjectInternal projectInternal = (ProjectInternal) project;
project.getPluginManager().apply(JavaBasePlugin.class);
project.getPluginManager().apply("org.gradle.jvm-test-suite");
JavaPluginExtension javaExtension = project.getExtensions().getByType(JavaPluginExtension.class);
projectInternal.getServices().get(ComponentRegistry.class).setMainComponent(new BuildableJavaComponentImpl(project, javaExtension));
BuildOutputCleanupRegistry buildOutputCleanupRegistry = projectInternal.getServices().get(BuildOutputCleanupRegistry.class);
SourceSet mainSourceSet = javaExtension.getSourceSets().create(SourceSet.MAIN_SOURCE_SET_NAME);
configureSourceSets(project, javaExtension, buildOutputCleanupRegistry, mainSourceSet);
configureConfigurations(project, javaExtension, mainSourceSet);
configureJavadocTask(project, javaExtension);
configureArchivesAndComponent(project, javaExtension);
configureBuild(project);
}
use of org.gradle.api.tasks.SourceSet in project gradle by gradle.
the class JavaPlugin method configureJavadocTask.
private void configureJavadocTask(Project project, JavaPluginExtension javaPluginExtension) {
SourceSet main = mainSourceSetOf(javaPluginExtension);
configureJavaDocTask(null, main, project.getTasks(), javaPluginExtension);
}
use of org.gradle.api.tasks.SourceSet in project gradle by gradle.
the class JavaTestFixturesPlugin method createImplicitTestFixturesDependencies.
private void createImplicitTestFixturesDependencies(Project project, JavaPluginExtension extension) {
DependencyHandler dependencies = project.getDependencies();
dependencies.add(TEST_FIXTURES_API, dependencies.create(project));
SourceSet testSourceSet = findTestSourceSet(extension);
ProjectDependency testDependency = (ProjectDependency) dependencies.add(testSourceSet.getImplementationConfigurationName(), dependencies.create(project));
testDependency.capabilities(new ProjectTestFixtures(project));
// Overwrite what the Java plugin defines for test, in order to avoid duplicate classes
// see gradle/gradle#10872
ConfigurationContainer configurations = project.getConfigurations();
testSourceSet.setCompileClasspath(project.getObjects().fileCollection().from(configurations.getByName(TEST_COMPILE_CLASSPATH_CONFIGURATION_NAME)));
testSourceSet.setRuntimeClasspath(project.getObjects().fileCollection().from(testSourceSet.getOutput(), configurations.getByName(TEST_RUNTIME_CLASSPATH_CONFIGURATION_NAME)));
}
Aggregations