use of org.gradle.api.tasks.SourceSet in project gradle by gradle.
the class JavaPlugin method configureSourceSets.
private void configureSourceSets(JavaPluginConvention pluginConvention, final BuildOutputCleanupRegistry buildOutputCleanupRegistry) {
Project project = pluginConvention.getProject();
SourceSet main = pluginConvention.getSourceSets().create(SourceSet.MAIN_SOURCE_SET_NAME);
SourceSet test = pluginConvention.getSourceSets().create(SourceSet.TEST_SOURCE_SET_NAME);
test.setCompileClasspath(project.files(main.getOutput(), project.getConfigurations().getByName(TEST_COMPILE_CLASSPATH_CONFIGURATION_NAME)));
test.setRuntimeClasspath(project.files(test.getOutput(), main.getOutput(), project.getConfigurations().getByName(TEST_RUNTIME_CLASSPATH_CONFIGURATION_NAME)));
// Register the project's source set output directories
pluginConvention.getSourceSets().all(new Action<SourceSet>() {
@Override
public void execute(SourceSet sourceSet) {
buildOutputCleanupRegistry.registerOutputs(sourceSet.getOutput());
}
});
}
use of org.gradle.api.tasks.SourceSet in project gradle by gradle.
the class ScalaBasePlugin method configureSourceSetDefaults.
private static void configureSourceSetDefaults(final Project project, final SourceDirectorySetFactory sourceDirectorySetFactory) {
final JavaBasePlugin javaPlugin = project.getPlugins().getPlugin(JavaBasePlugin.class);
project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all(new Action<SourceSet>() {
@Override
public void execute(final SourceSet sourceSet) {
String displayName = (String) InvokerHelper.invokeMethod(sourceSet, "getDisplayName", null);
Convention sourceSetConvention = (Convention) InvokerHelper.getProperty(sourceSet, "convention");
DefaultScalaSourceSet scalaSourceSet = new DefaultScalaSourceSet(displayName, sourceDirectorySetFactory);
sourceSetConvention.getPlugins().put("scala", scalaSourceSet);
final SourceDirectorySet scalaDirectorySet = scalaSourceSet.getScala();
scalaDirectorySet.srcDir(new Callable<File>() {
@Override
public File call() throws Exception {
return project.file("src/" + sourceSet.getName() + "/scala");
}
});
sourceSet.getAllJava().source(scalaDirectorySet);
sourceSet.getAllSource().source(scalaDirectorySet);
sourceSet.getResources().getFilter().exclude(new Spec<FileTreeElement>() {
@Override
public boolean isSatisfiedBy(FileTreeElement element) {
return scalaDirectorySet.contains(element.getFile());
}
});
configureScalaCompile(project, javaPlugin, sourceSet);
}
});
}
use of org.gradle.api.tasks.SourceSet in project gradle by gradle.
the class ScalaPlugin method configureScaladoc.
private static void configureScaladoc(final Project project) {
project.getTasks().withType(ScalaDoc.class, new Action<ScalaDoc>() {
@Override
public void execute(ScalaDoc scalaDoc) {
final SourceSet main = project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().getByName("main");
scalaDoc.getConventionMapping().map("classpath", new Callable<FileCollection>() {
@Override
public FileCollection call() throws Exception {
ConfigurableFileCollection files = project.files();
files.from(main.getOutput());
files.from(main.getCompileClasspath());
return files;
}
});
scalaDoc.setSource(InvokerHelper.invokeMethod(main, "getScala", null));
}
});
ScalaDoc scalaDoc = project.getTasks().create(SCALA_DOC_TASK_NAME, ScalaDoc.class);
scalaDoc.setDescription("Generates Scaladoc for the main source code.");
scalaDoc.setGroup(JavaBasePlugin.DOCUMENTATION_GROUP);
}
use of org.gradle.api.tasks.SourceSet in project gradle by gradle.
the class SourceFoldersCreator method projectRelativeFolders.
private List<SourceFolder> projectRelativeFolders(Iterable<SourceSet> sourceSets, Function<File, String> provideRelativePath) {
ArrayList<SourceFolder> entries = Lists.newArrayList();
List<SourceSet> sortedSourceSets = sortSourceSetsAsPerUsualConvention(sourceSets);
for (SourceSet sourceSet : sortedSourceSets) {
List<DirectoryTree> sortedSourceDirs = sortSourceDirsAsPerUsualConvention(sourceSet.getAllSource().getSrcDirTrees());
for (DirectoryTree tree : sortedSourceDirs) {
File dir = tree.getDir();
if (dir.isDirectory()) {
String relativePath = provideRelativePath.apply(dir);
SourceFolder folder = new SourceFolder(relativePath, null);
folder.setDir(dir);
folder.setName(dir.getName());
folder.setIncludes(getIncludesForTree(sourceSet, tree));
folder.setExcludes(getExcludesForTree(sourceSet, tree));
entries.add(folder);
}
}
}
return entries;
}
use of org.gradle.api.tasks.SourceSet in project spring-boot by spring-projects.
the class RunPluginFeatures method mainClassNameFinder.
private void mainClassNameFinder(Project project) {
FindMainClassTask findMainClassTask = project.getTasks().create(FIND_MAIN_CLASS_TASK_NAME, FindMainClassTask.class);
SourceSet mainSourceSet = SourceSets.findMainSourceSet(project);
if (mainSourceSet != null) {
findMainClassTask.setMainClassSourceSetOutput(mainSourceSet.getOutput());
}
project.getTasks().all(new Action<Task>() {
@Override
public void execute(Task task) {
if (task instanceof BootRunTask || task instanceof CreateStartScripts) {
task.dependsOn(FIND_MAIN_CLASS_TASK_NAME);
}
}
});
}
Aggregations