Search in sources :

Example 1 with MavenProjectChanges

use of org.jetbrains.idea.maven.project.MavenProjectChanges 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 2 with MavenProjectChanges

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

the class MavenProjectsTreeReadingTest method testSendingNotificationsWhenResolveFailed.

public void testSendingNotificationsWhenResolveFailed() throws Exception {
    createProjectPom("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<version>1</version>" + "<name");
    updateAll(myProjectPom);
    MyLoggingListener listener = new MyLoggingListener();
    myTree.addListener(listener);
    MavenProject project = myTree.findProject(myProjectPom);
    MavenEmbeddersManager embeddersManager = new MavenEmbeddersManager(myProject);
    final List<NativeMavenProjectHolder> nativeProject = new ArrayList<>();
    try {
        myTree.addListener(new MavenProjectsTree.Listener() {

            @Override
            public void projectResolved(Pair<MavenProject, MavenProjectChanges> projectWithChanges, NativeMavenProjectHolder nativeMavenProject) {
                nativeProject.add(nativeMavenProject);
            }
        });
        myTree.resolve(myProject, project, getMavenGeneralSettings(), embeddersManager, NULL_MAVEN_CONSOLE, EMPTY_MAVEN_PROCESS);
    } finally {
        embeddersManager.releaseInTests();
    }
    assertEquals("resolved: project ", listener.log);
    assertTrue(project.hasReadingProblems());
    assertSize(1, nativeProject);
    assertNull(nativeProject.get(0));
}
Also used : 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) ArrayList(java.util.ArrayList) MavenEmbeddersManager(org.jetbrains.idea.maven.project.MavenEmbeddersManager)

Aggregations

MavenEmbeddersManager (org.jetbrains.idea.maven.project.MavenEmbeddersManager)2 MavenProject (org.jetbrains.idea.maven.project.MavenProject)2 MavenProjectChanges (org.jetbrains.idea.maven.project.MavenProjectChanges)2 MavenProjectsTree (org.jetbrains.idea.maven.project.MavenProjectsTree)2 NativeMavenProjectHolder (org.jetbrains.idea.maven.server.NativeMavenProjectHolder)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 ArrayList (java.util.ArrayList)1