Search in sources :

Example 1 with Url

use of org.jetbrains.idea.maven.utils.Url in project intellij-community by JetBrains.

the class MavenRootModelAdapter method addSourceFolder.

private <P extends JpsElement> void addSourceFolder(@NotNull String path, @NotNull final JpsModuleSourceRootType<P> rootType, boolean ifNotEmpty, @NotNull final P properties) {
    if (ifNotEmpty) {
        String[] childs = new File(toPath(path).getPath()).list();
        if (childs == null || childs.length == 0)
            return;
    } else {
        if (!exists(path))
            return;
    }
    Url url = toUrl(path);
    myRootModelModuleExtension.addSourceFolder(url, rootType, properties);
}
Also used : File(java.io.File) Url(org.jetbrains.idea.maven.utils.Url)

Example 2 with Url

use of org.jetbrains.idea.maven.utils.Url in project intellij-community by JetBrains.

the class MavenRootModelAdapter method hasCollision.

public boolean hasCollision(String sourceRootPath) {
    Url url = toUrl(sourceRootPath);
    for (ContentEntry eachEntry : myRootModel.getContentEntries()) {
        for (SourceFolder eachFolder : eachEntry.getSourceFolders()) {
            String ancestor = url.getUrl();
            String child = eachFolder.getUrl();
            if (VfsUtilCore.isEqualOrAncestor(ancestor, child) || VfsUtilCore.isEqualOrAncestor(child, ancestor)) {
                return true;
            }
        }
        for (String excludeUrl : eachEntry.getExcludeFolderUrls()) {
            String ancestor = url.getUrl();
            if (VfsUtilCore.isEqualOrAncestor(ancestor, excludeUrl) || VfsUtilCore.isEqualOrAncestor(excludeUrl, ancestor)) {
                return true;
            }
        }
    }
    return false;
}
Also used : Url(org.jetbrains.idea.maven.utils.Url)

Example 3 with Url

use of org.jetbrains.idea.maven.utils.Url in project intellij-community by JetBrains.

the class MavenRootModelAdapter method unregisterAll.

public void unregisterAll(String path, boolean under, boolean unregisterSources) {
    Url url = toUrl(path);
    for (ContentEntry eachEntry : myRootModel.getContentEntries()) {
        if (unregisterSources) {
            myRootModelModuleExtension.unregisterAll(url, under);
        }
        for (String excludedUrl : eachEntry.getExcludeFolderUrls()) {
            String ancestor = under ? url.getUrl() : excludedUrl;
            String child = under ? excludedUrl : url.getUrl();
            if (VfsUtilCore.isEqualOrAncestor(ancestor, child)) {
                eachEntry.removeExcludeFolder(excludedUrl);
            }
        }
        for (String outputUrl : getCompilerExtension().getOutputRootUrls(true)) {
            String ancestor = under ? url.getUrl() : outputUrl;
            String child = under ? outputUrl : url.getUrl();
            if (VfsUtilCore.isEqualOrAncestor(ancestor, child)) {
                getCompilerExtension().setExcludeOutput(false);
            }
        }
    }
}
Also used : Url(org.jetbrains.idea.maven.utils.Url)

Example 4 with Url

use of org.jetbrains.idea.maven.utils.Url in project intellij-community by JetBrains.

the class MavenRootModelAdapter method addExcludedFolder.

public void addExcludedFolder(String path) {
    unregisterAll(path, true, false);
    Url url = toUrl(path);
    ContentEntry e = getContentRootFor(url);
    if (e == null)
        return;
    if (e.getUrl().equals(url.getUrl()))
        return;
    e.addExcludeFolder(url.getUrl());
    if (!Registry.is("ide.hide.excluded.files")) {
        Project project = myRootModel.getProject();
        ChangeListManager.getInstance(project).addDirectoryToIgnoreImplicitly(toPath(path).getPath());
    }
}
Also used : Project(com.intellij.openapi.project.Project) MavenProject(org.jetbrains.idea.maven.project.MavenProject) Url(org.jetbrains.idea.maven.utils.Url)

Example 5 with Url

use of org.jetbrains.idea.maven.utils.Url in project intellij-community by JetBrains.

the class MavenRootModelAdapter method initContentRoots.

private void initContentRoots() {
    Url url = toUrl(myMavenProject.getDirectory());
    if (getContentRootFor(url) != null)
        return;
    myRootModel.addContentEntry(url.getUrl());
}
Also used : Url(org.jetbrains.idea.maven.utils.Url)

Aggregations

Url (org.jetbrains.idea.maven.utils.Url)6 Project (com.intellij.openapi.project.Project)1 JpsContentEntry (com.intellij.project.model.impl.module.content.JpsContentEntry)1 JpsSourceFolder (com.intellij.project.model.impl.module.content.JpsSourceFolder)1 File (java.io.File)1 MavenProject (org.jetbrains.idea.maven.project.MavenProject)1 JpsElement (org.jetbrains.jps.model.JpsElement)1 JpsElementBase (org.jetbrains.jps.model.ex.JpsElementBase)1 JavaSourceRootProperties (org.jetbrains.jps.model.java.JavaSourceRootProperties)1 JavaSourceRootType (org.jetbrains.jps.model.java.JavaSourceRootType)1 JpsModuleSourceRootType (org.jetbrains.jps.model.module.JpsModuleSourceRootType)1