Search in sources :

Example 61 with MavenProject

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

the class MavenProjectsTreeReadingTest method testUpdatingModelWhenParentProfilesXmlChangeAndItIsAModuleAlso.

public void testUpdatingModelWhenParentProfilesXmlChangeAndItIsAModuleAlso() throws Exception {
    createProjectPom("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>" + "<packaging>pom</packaging>" + "<modules>" + "  <module>m</module>" + "</modules>");
    createProfilesXmlOldStyle("<profile>" + "  <id>one</id>" + "  <activation>" + "    <activeByDefault>true</activeByDefault>" + "  </activation>" + "  <properties>" + "    <prop>value1</prop>" + "  </properties>" + "</profile>");
    createModulePom("m", "<groupId>test</groupId>" + "<artifactId>m</artifactId>" + "<version>1</version>" + "<parent>" + "  <groupId>test</groupId>" + "  <artifactId>project</artifactId>" + "  <version>1</version>" + "</parent>" + "<build>" + "  <sourceDirectory>${prop}</sourceDirectory>" + "</build>");
    updateAll(myProjectPom);
    MavenProject childNode = myTree.getModules(myTree.getRootProjects().get(0)).get(0);
    assertUnorderedPathsAreEqual(childNode.getSources(), Arrays.asList(FileUtil.toSystemDependentName(getProjectPath() + "/m/value1")));
    createProfilesXmlOldStyle("<profile>" + "  <id>one</id>" + "  <activation>" + "    <activeByDefault>true</activeByDefault>" + "  </activation>" + "  <properties>" + "    <prop>value2</prop>" + "  </properties>" + "</profile>");
    updateAll(myProjectPom);
    assertUnorderedPathsAreEqual(childNode.getSources(), Arrays.asList(FileUtil.toSystemDependentName(getProjectPath() + "/m/value2")));
}
Also used : MavenProject(org.jetbrains.idea.maven.project.MavenProject)

Example 62 with MavenProject

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

the class MavenProjectsTreeReadingTest method testUpdatingParticularProject.

public void testUpdatingParticularProject() throws Exception {
    createProjectPom("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>" + "<packaging>pom</packaging>" + "<modules>" + "  <module>m</module>" + "</modules>");
    VirtualFile m = createModulePom("m", "<groupId>test</groupId>" + "<artifactId>m</artifactId>" + "<version>1</version>");
    updateAll(myProjectPom);
    createModulePom("m", "<groupId>test</groupId>" + "<artifactId>m1</artifactId>" + "<version>1</version>");
    update(m);
    MavenProject n = myTree.findProject(m);
    assertEquals("m1", n.getMavenId().getArtifactId());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) MavenProject(org.jetbrains.idea.maven.project.MavenProject)

Example 63 with MavenProject

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

the class MavenProjectsTreeReadingTest method testDoNotUpdateChildAfterParentWasResolved.

public void testDoNotUpdateChildAfterParentWasResolved() throws Exception {
    createProjectPom("<groupId>test</groupId>" + "<artifactId>parent</artifactId>" + "<version>1</version>");
    VirtualFile child = createModulePom("child", "<groupId>test</groupId>" + "<artifactId>child</artifactId>" + "<version>1</version>" + "<parent>" + "  <groupId>test</groupId>" + "  <artifactId>parent</artifactId>" + "  <version>1</version>" + "</parent>");
    MyLoggingListener listener = new MyLoggingListener();
    myTree.addListener(listener);
    updateAll(myProjectPom, child);
    MavenProject parentProject = myTree.findProject(myProjectPom);
    MavenEmbeddersManager embeddersManager = new MavenEmbeddersManager(myProject);
    try {
        final NativeMavenProjectHolder[] nativeProject = new NativeMavenProjectHolder[1];
        myTree.addListener(new MavenProjectsTree.Listener() {

            @Override
            public void projectResolved(Pair<MavenProject, MavenProjectChanges> projectWithChanges, NativeMavenProjectHolder nativeMavenProject) {
                nativeProject[0] = nativeMavenProject;
            }
        });
        myTree.resolve(myProject, parentProject, getMavenGeneralSettings(), embeddersManager, NULL_MAVEN_CONSOLE, EMPTY_MAVEN_PROCESS);
        myTree.resolvePlugins(parentProject, nativeProject[0], embeddersManager, NULL_MAVEN_CONSOLE, EMPTY_MAVEN_PROCESS);
        myTree.resolveFolders(parentProject, getMavenImporterSettings(), embeddersManager, NULL_MAVEN_CONSOLE, EMPTY_MAVEN_PROCESS);
    } finally {
        embeddersManager.releaseInTests();
    }
    assertEquals("updated: parent child deleted: <none> resolved: parent plugins: parent folders: parent ", listener.log);
    myTree.updateAll(false, getMavenGeneralSettings(), EMPTY_MAVEN_PROCESS);
    assertEquals("updated: parent child deleted: <none> resolved: parent plugins: parent folders: parent ", listener.log);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) MavenProjectChanges(org.jetbrains.idea.maven.project.MavenProjectChanges) MavenProject(org.jetbrains.idea.maven.project.MavenProject) NativeMavenProjectHolder(org.jetbrains.idea.maven.server.NativeMavenProjectHolder) MavenProjectsTree(org.jetbrains.idea.maven.project.MavenProjectsTree) MavenEmbeddersManager(org.jetbrains.idea.maven.project.MavenEmbeddersManager)

Example 64 with MavenProject

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

the class MavenProjectsTreeReadingTest method testReconnectModuleOfDeletedProjectIfModuleIsManaged.

public void testReconnectModuleOfDeletedProjectIfModuleIsManaged() throws Exception {
    createProjectPom("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>" + "<packaging>pom</packaging>" + "<modules>" + "  <module>m1</module>" + "</modules>");
    VirtualFile m1 = createModulePom("m1", "<groupId>test</groupId>" + "<artifactId>m1</artifactId>" + "<version>1</version>" + "<packaging>pom</packaging>" + "<modules>" + "  <module>m2</module>" + "</modules>");
    VirtualFile m2 = createModulePom("m1/m2", "<groupId>test</groupId>" + "<artifactId>m2</artifactId>" + "<version>1</version>");
    updateAll(myProjectPom, m2);
    List<MavenProject> roots = myTree.getRootProjects();
    assertEquals(1, roots.size());
    assertEquals(1, myTree.getModules(roots.get(0)).size());
    assertEquals(1, myTree.getModules(myTree.getModules(roots.get(0)).get(0)).size());
    MyLoggingListener listener = new MyLoggingListener();
    myTree.addListener(listener);
    deleteProject(m1);
    roots = myTree.getRootProjects();
    assertEquals(2, roots.size());
    assertEquals(myProjectPom, roots.get(0).getFile());
    assertEquals(0, myTree.getModules(roots.get(0)).size());
    assertEquals(m2, roots.get(1).getFile());
    assertEquals(0, myTree.getModules(roots.get(1)).size());
    assertEquals("updated: m2 deleted: m1 ", listener.log);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) MavenProject(org.jetbrains.idea.maven.project.MavenProject)

Example 65 with MavenProject

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

the class DependenciesImportingTest method testInterModuleDependenciesWithReleaseVersion.

public void testInterModuleDependenciesWithReleaseVersion() throws Exception {
    createProjectPom("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<packaging>pom</packaging>" + "<version>1</version>" + "<modules>" + "  <module>m1</module>" + "  <module>m2</module>" + "</modules>");
    createModulePom("m1", "<groupId>test</groupId>" + "<artifactId>m1</artifactId>" + "<version>1</version>" + "<dependencies>" + "  <dependency>" + "    <groupId>test</groupId>" + "    <artifactId>m2</artifactId>" + "    <version>RELEASE</version>" + "  </dependency>" + "</dependencies>");
    createModulePom("m2", "<groupId>test</groupId>" + "<artifactId>m2</artifactId>" + "<version>1</version>");
    importProject();
    assertModules("project", "m1", "m2");
    assertModuleModuleDeps("m1", "m2");
    assertModuleLibDeps("m1");
    MavenProject p = myProjectsTree.findProject(new MavenId("test", "m1", "1"));
    assertEquals(new MavenId("test", "m2", "1"), p.getDependencies().get(0).getMavenId());
}
Also used : MavenId(org.jetbrains.idea.maven.model.MavenId) MavenProject(org.jetbrains.idea.maven.project.MavenProject)

Aggregations

MavenProject (org.jetbrains.idea.maven.project.MavenProject)132 VirtualFile (com.intellij.openapi.vfs.VirtualFile)40 MavenProjectsManager (org.jetbrains.idea.maven.project.MavenProjectsManager)20 MavenId (org.jetbrains.idea.maven.model.MavenId)16 Project (com.intellij.openapi.project.Project)10 Nullable (org.jetbrains.annotations.Nullable)9 Bombed (com.intellij.idea.Bombed)8 Module (com.intellij.openapi.module.Module)6 DataContext (com.intellij.openapi.actionSystem.DataContext)5 File (java.io.File)5 ArrayList (java.util.ArrayList)5 Result (com.intellij.openapi.application.Result)4 MavenArtifact (org.jetbrains.idea.maven.model.MavenArtifact)4 MavenEmbeddersManager (org.jetbrains.idea.maven.project.MavenEmbeddersManager)4 WriteCommandAction (com.intellij.openapi.command.WriteCommandAction)3 TextRange (com.intellij.openapi.util.TextRange)3 NotNull (org.jetbrains.annotations.NotNull)3 MavenRunnerParameters (org.jetbrains.idea.maven.execution.MavenRunnerParameters)3 MavenExplicitProfiles (org.jetbrains.idea.maven.model.MavenExplicitProfiles)3 MavenProjectsTree (org.jetbrains.idea.maven.project.MavenProjectsTree)3