use of org.gradle.plugins.ide.eclipse.model.SourceFolder in project gradle by gradle.
the class SourceFoldersCreator method projectRelativeFolders.
private List<SourceFolder> projectRelativeFolders(Iterable<SourceSet> sourceSets, Function<File, String> provideRelativePath, File defaultOutputDir) {
String defaultOutputPath = PathUtil.normalizePath(provideRelativePath.apply(defaultOutputDir));
ArrayList<SourceFolder> entries = Lists.newArrayList();
List<SourceSet> sortedSourceSets = sortSourceSetsAsPerUsualConvention(sourceSets);
Map<SourceSet, String> sourceSetOutputPaths = collectSourceSetOutputPaths(sortedSourceSets, defaultOutputPath);
Multimap<SourceSet, SourceSet> sourceSetUsages = getSourceSetUsages(sortedSourceSets);
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));
folder.setOutput(sourceSetOutputPaths.get(sourceSet));
addScopeAttributes(folder, sourceSet, sourceSetUsages);
entries.add(folder);
}
}
}
return entries;
}
use of org.gradle.plugins.ide.eclipse.model.SourceFolder in project gradle by gradle.
the class SourceFoldersCreator method configureProjectRelativeFolders.
private List<SourceFolder> configureProjectRelativeFolders(Iterable<SourceSet> sourceSets, Collection<SourceSet> testSourceSets, Function<File, String> provideRelativePath, File defaultOutputDir) {
String defaultOutputPath = PathUtil.normalizePath(provideRelativePath.apply(defaultOutputDir));
ArrayList<SourceFolder> entries = Lists.newArrayList();
List<SourceSet> sortedSourceSets = sortSourceSetsAsPerUsualConvention(sourceSets);
Map<SourceSet, String> sourceSetOutputPaths = collectSourceSetOutputPaths(sortedSourceSets, defaultOutputPath);
Multimap<SourceSet, SourceSet> sourceSetUsages = getSourceSetUsages(sortedSourceSets);
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));
folder.setOutput(sourceSetOutputPaths.get(sourceSet));
addScopeAttributes(folder, sourceSet, sourceSetUsages);
addSourceSetAttributeIfNeeded(sourceSet, folder, testSourceSets);
entries.add(folder);
}
}
}
return entries;
}
use of org.gradle.plugins.ide.eclipse.model.SourceFolder in project gradle by gradle.
the class LinkedResourcesCreator method links.
public Set<Link> links(final Project project) {
SourceSetContainer sourceSets = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets();
EclipseClasspath classpath = project.getExtensions().getByType(EclipseModel.class).getClasspath();
File defaultOutputDir = classpath == null ? project.file(EclipsePluginConstants.DEFAULT_PROJECT_OUTPUT_PATH) : classpath.getDefaultOutputDir();
List<SourceFolder> sourceFolders = new SourceFoldersCreator().getBasicExternalSourceFolders(sourceSets, new Function<File, String>() {
@Override
public String apply(File dir) {
return project.relativePath(dir);
}
}, defaultOutputDir);
Set<Link> links = Sets.newLinkedHashSetWithExpectedSize(sourceFolders.size());
for (SourceFolder sourceFolder : sourceFolders) {
links.add(new Link(sourceFolder.getName(), "2", sourceFolder.getAbsolutePath(), null));
}
return links;
}
Aggregations