use of org.gradle.api.tasks.SourceSet in project spring-boot by spring-projects.
the class ConfigurationPropertiesPlugin method configureAdditionalMetadataLocationsCompilerArgument.
private void configureAdditionalMetadataLocationsCompilerArgument(Project project) {
JavaCompile compileJava = project.getTasks().withType(JavaCompile.class).getByName(JavaPlugin.COMPILE_JAVA_TASK_NAME);
((Task) compileJava).getInputs().files(project.getTasks().getByName(JavaPlugin.PROCESS_RESOURCES_TASK_NAME)).withPathSensitivity(PathSensitivity.RELATIVE).withPropertyName("processed resources");
SourceSet mainSourceSet = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
compileJava.getOptions().getCompilerArgs().add("-Aorg.springframework.boot.configurationprocessor.additionalMetadataLocations=" + StringUtils.collectionToCommaDelimitedString(mainSourceSet.getResources().getSourceDirectories().getFiles().stream().map(project.getRootProject()::relativePath).collect(Collectors.toSet())));
}
use of org.gradle.api.tasks.SourceSet in project spring-boot by spring-projects.
the class ConfigurationPropertiesPlugin method addMetadataArtifact.
private void addMetadataArtifact(Project project) {
SourceSet mainSourceSet = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
project.getConfigurations().maybeCreate(CONFIGURATION_PROPERTIES_METADATA_CONFIGURATION_NAME);
project.afterEvaluate((evaluatedProject) -> evaluatedProject.getArtifacts().add(CONFIGURATION_PROPERTIES_METADATA_CONFIGURATION_NAME, mainSourceSet.getJava().getDestinationDirectory().dir("META-INF/spring-configuration-metadata.json"), (artifact) -> artifact.builtBy(evaluatedProject.getTasks().getByName(mainSourceSet.getClassesTaskName()))));
}
use of org.gradle.api.tasks.SourceSet in project gradle by gradle.
the class GroovyPlugin method configureGroovydoc.
private void configureGroovydoc(final Project project) {
Groovydoc groovyDoc = project.getTasks().create(GROOVYDOC_TASK_NAME, Groovydoc.class);
groovyDoc.setDescription("Generates Groovydoc API documentation for the main source code.");
groovyDoc.setGroup(JavaBasePlugin.DOCUMENTATION_GROUP);
JavaPluginConvention convention = project.getConvention().getPlugin(JavaPluginConvention.class);
SourceSet sourceSet = convention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
groovyDoc.setClasspath(sourceSet.getOutput().plus(sourceSet.getCompileClasspath()));
GroovySourceSet groovySourceSet = new DslObject(sourceSet).getConvention().getPlugin(GroovySourceSet.class);
groovyDoc.setSource(groovySourceSet.getGroovy());
}
use of org.gradle.api.tasks.SourceSet 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);
}
use of org.gradle.api.tasks.SourceSet in project gradle by gradle.
the class DefaultSourceSetContainerTest method createsASourceSet.
@Test
public void createsASourceSet() {
SourceSet set = container.create("main");
assertThat(set, instanceOf(DefaultSourceSet.class));
assertThat(set.getName(), equalTo("main"));
}
Aggregations