Search in sources :

Example 46 with MavenProjectsManager

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

the class MavenActionUtil method getMavenProject.

@Nullable
public static MavenProject getMavenProject(DataContext context) {
    MavenProject result;
    final MavenProjectsManager manager = getProjectsManager(context);
    if (manager == null)
        return null;
    final VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(context);
    if (file != null) {
        result = manager.findProject(file);
        if (result != null)
            return result;
    }
    Module module = ExternalSystemActionUtil.getModule(context);
    if (module != null) {
        result = manager.findProject(module);
        if (result != null)
            return result;
    }
    return null;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) MavenProject(org.jetbrains.idea.maven.project.MavenProject) MavenProjectsManager(org.jetbrains.idea.maven.project.MavenProjectsManager) Module(com.intellij.openapi.module.Module) Nullable(org.jetbrains.annotations.Nullable)

Example 47 with MavenProjectsManager

use of org.jetbrains.idea.maven.project.MavenProjectsManager in project google-cloud-intellij by GoogleCloudPlatform.

the class DefaultAppEngineProjectService method isJarOrWarMavenBuild.

@Override
public boolean isJarOrWarMavenBuild(@NotNull Module module) {
    MavenProjectsManager projectsManager = MavenProjectsManager.getInstance(module.getProject());
    MavenProject mavenProject = projectsManager.findProject(module);
    return mavenProject != null && isMavenModule(module) && ("jar".equalsIgnoreCase(mavenProject.getPackaging()) || "war".equalsIgnoreCase(mavenProject.getPackaging()));
}
Also used : MavenProjectsManager(org.jetbrains.idea.maven.project.MavenProjectsManager) MavenProject(org.jetbrains.idea.maven.project.MavenProject)

Example 48 with MavenProjectsManager

use of org.jetbrains.idea.maven.project.MavenProjectsManager in project azure-tools-for-java by Microsoft.

the class MavenProjectGenerator method importMavenProject.

private Promise<MavenProject> importMavenProject() {
    Project project = this.module.getProject();
    String baseDirPath = project.getBasePath();
    MavenProjectsManager manager = MavenProjectsManager.getInstance(project);
    File pomFile = new File(baseDirPath + File.separator + "pom.xml");
    VirtualFile pom = VfsUtil.findFileByIoFile(pomFile, true);
    if (pom == null) {
        return Promises.rejectedPromise("Can't find Maven pom.xml file to import into IDEA");
    }
    manager.addManagedFiles(Collections.singletonList(pom));
    return manager.scheduleImportAndResolve().then(modules -> manager.findProject(module));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) MavenProject(org.jetbrains.idea.maven.project.MavenProject) Project(com.intellij.openapi.project.Project) MavenProjectsManager(org.jetbrains.idea.maven.project.MavenProjectsManager) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 49 with MavenProjectsManager

use of org.jetbrains.idea.maven.project.MavenProjectsManager in project azure-tools-for-java by Microsoft.

the class MavenUtils method evaluateEffectivePom.

public static String evaluateEffectivePom(@NotNull Project ideaProject, @NotNull MavenProject mavenProject) throws MavenProcessCanceledException {
    final MavenProjectsManager projectsManager = MavenProjectsManager.getInstance(ideaProject);
    final MavenEmbeddersManager embeddersManager = projectsManager.getEmbeddersManager();
    final MavenExplicitProfiles profiles = mavenProject.getActivatedProfilesIds();
    final MavenEmbedderWrapper embedder = embeddersManager.getEmbedder(mavenProject, MavenEmbeddersManager.FOR_DEPENDENCIES_RESOLVE);
    embedder.clearCachesFor(mavenProject.getMavenId());
    return embedder.evaluateEffectivePom(mavenProject.getFile(), profiles.getEnabledProfiles(), profiles.getDisabledProfiles());
}
Also used : MavenProjectsManager(org.jetbrains.idea.maven.project.MavenProjectsManager) MavenExplicitProfiles(org.jetbrains.idea.maven.model.MavenExplicitProfiles) MavenEmbeddersManager(org.jetbrains.idea.maven.project.MavenEmbeddersManager) MavenEmbedderWrapper(org.jetbrains.idea.maven.server.MavenEmbedderWrapper)

Example 50 with MavenProjectsManager

use of org.jetbrains.idea.maven.project.MavenProjectsManager in project moe-ide-integration by multi-os-engine.

the class ModuleUtils method isMOEMavenModule.

public static boolean isMOEMavenModule(@NotNull Module module) {
    if (!isMavenSupport()) {
        return false;
    }
    String pomXmlPath = findPomXml(module);
    if (pomXmlPath == null || pomXmlPath.isEmpty()) {
        return false;
    }
    VirtualFile file = LocalFileSystem.getInstance().findFileByPath(pomXmlPath);
    if (file == null)
        return false;
    MavenProjectsManager manager = MavenProjectsManager.getInstance(module.getProject());
    if (manager == null) {
        return false;
    }
    MavenProject mavenProject = manager.findProject(file);
    if (mavenProject == null) {
        return false;
    }
    MavenPlugin mavenPlugin = mavenProject.findPlugin("org.multi-os-engine", "moe-maven");
    if (mavenPlugin != null) {
        return true;
    }
    return false;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) MavenProjectsManager(org.jetbrains.idea.maven.project.MavenProjectsManager) MavenProject(org.jetbrains.idea.maven.project.MavenProject) MavenPlugin(org.jetbrains.idea.maven.model.MavenPlugin)

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