Search in sources :

Example 16 with MavenProjectsManager

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

the class MavenExternalParameters method dumpModulesPaths.

private static File dumpModulesPaths(@NotNull Project project) throws IOException {
    ApplicationManager.getApplication().assertReadAccessAllowed();
    Properties res = new Properties();
    MavenProjectsManager manager = MavenProjectsManager.getInstance(project);
    for (Module module : ModuleManager.getInstance(project).getModules()) {
        if (manager.isMavenizedModule(module)) {
            MavenProject mavenProject = manager.findProject(module);
            if (mavenProject != null && !manager.isIgnored(mavenProject)) {
                res.setProperty(mavenProject.getMavenId().getGroupId() + ':' + mavenProject.getMavenId().getArtifactId() + ":pom" + ':' + mavenProject.getMavenId().getVersion(), mavenProject.getFile().getPath());
                res.setProperty(mavenProject.getMavenId().getGroupId() + ':' + mavenProject.getMavenId().getArtifactId() + ':' + mavenProject.getPackaging() + ':' + mavenProject.getMavenId().getVersion(), mavenProject.getOutputDirectory());
                res.setProperty(mavenProject.getMavenId().getGroupId() + ':' + mavenProject.getMavenId().getArtifactId() + ":test-jar" + ':' + mavenProject.getMavenId().getVersion(), mavenProject.getTestOutputDirectory());
                addArtifactFileMapping(res, mavenProject, "sources");
                addArtifactFileMapping(res, mavenProject, "test-sources");
                addArtifactFileMapping(res, mavenProject, "javadoc");
                addArtifactFileMapping(res, mavenProject, "test-javadoc");
            }
        }
    }
    File file = new File(PathManager.getSystemPath(), "Maven/idea-projects-state-" + project.getLocationHash() + ".properties");
    FileUtil.ensureExists(file.getParentFile());
    OutputStream out = new BufferedOutputStream(new FileOutputStream(file));
    try {
        res.store(out, null);
    } finally {
        out.close();
    }
    return file;
}
Also used : MavenProjectsManager(org.jetbrains.idea.maven.project.MavenProjectsManager) MavenProject(org.jetbrains.idea.maven.project.MavenProject) ZipOutputStream(java.util.zip.ZipOutputStream) Module(com.intellij.openapi.module.Module)

Example 17 with MavenProjectsManager

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

the class MavenModelInspection method isElementInsideManagedFile.

private static boolean isElementInsideManagedFile(GenericDomValue value) {
    VirtualFile virtualFile = DomUtil.getFile(value).getVirtualFile();
    if (virtualFile == null) {
        return false;
    }
    MavenProjectsManager projectsManager = MavenProjectsManager.getInstance(value.getManager().getProject());
    return projectsManager.findProject(virtualFile) != null;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) MavenProjectsManager(org.jetbrains.idea.maven.project.MavenProjectsManager)

Example 18 with MavenProjectsManager

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

the class MavenDomUtil method findContainingMavenizedModule.

@Nullable
public static Module findContainingMavenizedModule(@NotNull PsiFile psiFile) {
    VirtualFile file = psiFile.getVirtualFile();
    if (file == null)
        return null;
    Project project = psiFile.getProject();
    MavenProjectsManager manager = MavenProjectsManager.getInstance(project);
    if (!manager.isMavenizedProject())
        return null;
    ProjectFileIndex index = ProjectRootManager.getInstance(project).getFileIndex();
    Module module = index.getModuleForFile(file);
    if (module == null || !manager.isMavenizedModule(module))
        return null;
    return module;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) Project(com.intellij.openapi.project.Project) MavenProject(org.jetbrains.idea.maven.project.MavenProject) MavenProjectsManager(org.jetbrains.idea.maven.project.MavenProjectsManager) ProjectFileIndex(com.intellij.openapi.roots.ProjectFileIndex) Module(com.intellij.openapi.module.Module) Nullable(org.jetbrains.annotations.Nullable)

Example 19 with MavenProjectsManager

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

the class MavenDomUtil method findContainingProject.

@Nullable
public static MavenProject findContainingProject(@NotNull PsiElement element) {
    VirtualFile file = getVirtualFile(element);
    if (file == null)
        return null;
    MavenProjectsManager manager = MavenProjectsManager.getInstance(element.getProject());
    return manager.findContainingProject(file);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) MavenProjectsManager(org.jetbrains.idea.maven.project.MavenProjectsManager) Nullable(org.jetbrains.annotations.Nullable)

Example 20 with MavenProjectsManager

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

the class MavenPropertyResolver method doFilterText.

public static void doFilterText(Module module, String text, Properties additionalProperties, @Nullable String propertyEscapeString, Appendable out) throws IOException {
    MavenProjectsManager manager = MavenProjectsManager.getInstance(module.getProject());
    MavenProject mavenProject = manager.findProject(module);
    if (mavenProject == null) {
        out.append(text);
        return;
    }
    Element pluginConfiguration = mavenProject.getPluginConfiguration("org.apache.maven.plugins", "maven-resources-plugin");
    String escapeWindowsPathsStr = MavenJDOMUtil.findChildValueByPath(pluginConfiguration, "escapeWindowsPaths");
    boolean escapeWindowsPath = escapeWindowsPathsStr == null || Boolean.parseBoolean(escapeWindowsPathsStr);
    doFilterText(MavenFilteredPropertyPsiReferenceProvider.getDelimitersPattern(mavenProject), manager, mavenProject, text, additionalProperties, propertyEscapeString, escapeWindowsPath, null, out);
}
Also used : MavenProjectsManager(org.jetbrains.idea.maven.project.MavenProjectsManager) MavenProject(org.jetbrains.idea.maven.project.MavenProject) XmlElement(com.intellij.psi.xml.XmlElement) Element(org.jdom.Element)

Aggregations

MavenProjectsManager (org.jetbrains.idea.maven.project.MavenProjectsManager)52 MavenProject (org.jetbrains.idea.maven.project.MavenProject)29 VirtualFile (com.intellij.openapi.vfs.VirtualFile)24 Project (com.intellij.openapi.project.Project)13 Module (com.intellij.openapi.module.Module)8 File (java.io.File)8 Nullable (org.jetbrains.annotations.Nullable)8 DataContext (com.intellij.openapi.actionSystem.DataContext)6 PsiFile (com.intellij.psi.PsiFile)6 Notification (com.intellij.notification.Notification)4 LightVirtualFile (com.intellij.testFramework.LightVirtualFile)4 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 MavenRunnerParameters (org.jetbrains.idea.maven.execution.MavenRunnerParameters)4 MavenExplicitProfiles (org.jetbrains.idea.maven.model.MavenExplicitProfiles)4 NotificationListener (com.intellij.notification.NotificationListener)2 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)2 ProjectFileIndex (com.intellij.openapi.roots.ProjectFileIndex)2 XmlElement (com.intellij.psi.xml.XmlElement)2 List (java.util.List)2