コード例 #1
0
  public void test000_noChangeReload() throws Exception {
    IProject p1 = createExisting("t000-p1");
    IFile pom = p1.getFile(IMavenConstants.POM_FILE_NAME);
    waitForJobsToComplete();

    IMavenProjectFacade oldFacade = manager.create(p1, monitor);

    MavenProjectChangedEvent event;
    //    assertEquals(1, events.size());
    //    event = events.get(0);
    //    assertEquals(pom, event.getSource());
    //    assertEquals(MavenProjectChangedEvent.KIND_ADDED, event.getKind());

    events.clear();

    pom.setLocalTimeStamp(pom.getLocalTimeStamp() + 1000L);
    pom.touch(monitor);
    waitForJobsToComplete();

    IMavenProjectFacade newFacade = manager.create(p1, monitor);
    assertNotSame(oldFacade.getMavenProject(monitor), newFacade.getMavenProject(monitor));

    assertEquals(1, events.size());
    event = events.get(0);
    assertEquals(pom, event.getSource());
    assertEquals(MavenProjectChangedEvent.KIND_CHANGED, event.getKind());
    assertEquals(MavenProjectChangedEvent.FLAG_NONE, event.getFlags());
    assertNotNull(event.getOldMavenProject());
    assertNotNull(event.getMavenProject());
  }
コード例 #2
0
  public void test000_removeClosed() throws Exception {
    IProject p1 = createExisting("t000-p1");
    waitForJobsToComplete();

    IMavenProjectFacade f1 = manager.create(p1, monitor);

    MavenProjectChangedEvent event;
    //    assertEquals(1, events.size());
    //    event = events.get(0);
    //    assertEquals(MavenProjectChangedEvent.KIND_ADDED, event.getKind());
    //    assertNull(event.getOldMavenProject());
    //    assertSame(f1, event.getMavenProject());

    assertEquals(p1.getFullPath(), f1.getFullPath());

    events.clear();

    p1.close(monitor);
    waitForJobsToComplete();

    assertNull(manager.create(p1, monitor));

    assertEquals(1, events.size());
    event = events.get(0);
    assertEquals(MavenProjectChangedEvent.KIND_REMOVED, event.getKind());
    assertSame(f1, event.getOldMavenProject());
    assertNull(event.getMavenProject());
  }
  @Override
  public void mavenProjectChanged(
      final MavenProjectChangedEvent mavenProjectChangedEvent, final IProgressMonitor monitor)
      throws CoreException {
    final IMavenProjectFacade mavenProjectFacade = mavenProjectChangedEvent.getMavenProject();

    if (mavenProjectFacade != null) {
      final MavenProject mavenProject = mavenProjectFacade.getMavenProject();
      if (mavenProject == null) {
        return;
      }
      final MavenPluginWrapper pluginWrapper = this.getMavenPlugin(monitor, mavenProjectFacade);
      final IProject project = mavenProjectFacade.getProject();
      if (this.checkUnconfigurationRequired(
          monitor, mavenProjectFacade, mavenProjectChangedEvent.getOldMavenProject())) {
        this.unconfigureEclipsePlugin(project, monitor);
        return;
      }
      if (pluginWrapper.isPluginConfigured()) {
        // only call handler if maven plugin is configured or found.
        // we need a session.
        MavenExecutionRequest request = maven.createExecutionRequest(monitor);
        MavenSession session = maven.createSession(request, mavenProject);
        this.handleProjectConfigurationChange(
            session, mavenProjectFacade, project, monitor, pluginWrapper);
      } else {
        // TODO: redirect to eclipse logger.
        // this.console.logMessage(String.format(
        // "Will not configure the Eclipse Plugin for Maven Plugin [%s:%s],"
        // +
        // "(Could not find maven plugin instance or configuration in pom)",
        // this.getMavenPluginGroupId(),
        // this.getMavenPluginArtifactId()));
      }
    }
    super.mavenProjectChanged(mavenProjectChangedEvent, monitor);
  }