Search in sources :

Example 6 with SourceFolder

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;
}
Also used : SourceFolder(org.gradle.plugins.ide.eclipse.model.SourceFolder) SourceSet(org.gradle.api.tasks.SourceSet) DirectoryTree(org.gradle.api.file.DirectoryTree) File(java.io.File)

Example 7 with SourceFolder

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;
}
Also used : SourceFolder(org.gradle.plugins.ide.eclipse.model.SourceFolder) SourceSet(org.gradle.api.tasks.SourceSet) DirectoryTree(org.gradle.api.file.DirectoryTree) File(java.io.File)

Example 8 with SourceFolder

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;
}
Also used : SourceFoldersCreator(org.gradle.plugins.ide.eclipse.model.internal.SourceFoldersCreator) EclipseClasspath(org.gradle.plugins.ide.eclipse.model.EclipseClasspath) JavaPluginExtension(org.gradle.api.plugins.JavaPluginExtension) SourceSetContainer(org.gradle.api.tasks.SourceSetContainer) SourceFolder(org.gradle.plugins.ide.eclipse.model.SourceFolder) EclipseModel(org.gradle.plugins.ide.eclipse.model.EclipseModel) File(java.io.File) Link(org.gradle.plugins.ide.eclipse.model.Link)

Aggregations

File (java.io.File)8 SourceFolder (org.gradle.plugins.ide.eclipse.model.SourceFolder)8 DirectoryTree (org.gradle.api.file.DirectoryTree)4 SourceSet (org.gradle.api.tasks.SourceSet)4 EclipseClasspath (org.gradle.plugins.ide.eclipse.model.EclipseClasspath)2 HashMap (java.util.HashMap)1 JavaPluginExtension (org.gradle.api.plugins.JavaPluginExtension)1 SourceSetContainer (org.gradle.api.tasks.SourceSetContainer)1 AbstractClasspathEntry (org.gradle.plugins.ide.eclipse.model.AbstractClasspathEntry)1 AbstractLibrary (org.gradle.plugins.ide.eclipse.model.AbstractLibrary)1 Classpath (org.gradle.plugins.ide.eclipse.model.Classpath)1 ClasspathEntry (org.gradle.plugins.ide.eclipse.model.ClasspathEntry)1 Container (org.gradle.plugins.ide.eclipse.model.Container)1 EclipseModel (org.gradle.plugins.ide.eclipse.model.EclipseModel)1 Library (org.gradle.plugins.ide.eclipse.model.Library)1 Link (org.gradle.plugins.ide.eclipse.model.Link)1 Output (org.gradle.plugins.ide.eclipse.model.Output)1 ProjectDependency (org.gradle.plugins.ide.eclipse.model.ProjectDependency)1 UnresolvedLibrary (org.gradle.plugins.ide.eclipse.model.UnresolvedLibrary)1 SourceFoldersCreator (org.gradle.plugins.ide.eclipse.model.internal.SourceFoldersCreator)1