public void test008_staleMissingParent() throws Exception { // p1 does not have parent IProject p1 = createExisting("t008-p1"); assertNotNull(p1); IProject p3 = createExisting("t008-p3"); assertNotNull(p3); waitForJobsToComplete(); IMavenProjectFacade f1 = manager.create(p1, monitor); assertNull(f1); // XXX should I return non-null facade that does not have MavenProject? // update p1 to have p3 parent InputStream contents = p1.getFile("pom_updated.xml").getContents(); p1.getFile("pom.xml").setContents(contents, IResource.FORCE, monitor); contents.close(); waitForJobsToComplete(); f1 = manager.create(p1, monitor); assertEquals("t008-p3", getParentProject(f1).getArtifactId()); events.clear(); IProject p2 = createExisting("t008-p2"); waitForJobsToComplete(); assertEquals(1, events.size()); MavenProjectChangedEvent event = events.get(0); assertEquals(p2.getFile(IMavenConstants.POM_FILE_NAME), event.getSource()); assertEquals(MavenProjectChangedEvent.KIND_ADDED, event.getKind()); }
public void test007_staleDependencies() throws Exception { // p1 depends on p2 IProject p1 = createExisting("t007-p1"); IProject p2 = createExisting("t007-p2"); waitForJobsToComplete(); IMavenProjectFacade f1 = manager.create(p1, monitor); assertEquals(1, f1.getMavenProject(monitor).getArtifacts().size()); // update p1 to remove dependency on p2 copyContent(p1, "pom_updated.xml", "pom.xml"); f1 = manager.create(p1, monitor); assertEquals(0, f1.getMavenProject(monitor).getArtifacts().size()); events.clear(); // remove p2 deleteProject(p2); waitForJobsToComplete(); assertEquals(1, events.size()); MavenProjectChangedEvent event = events.get(0); assertEquals(p2.getFile(IMavenConstants.POM_FILE_NAME), event.getSource()); assertEquals(MavenProjectChangedEvent.KIND_REMOVED, event.getKind()); }
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()); }
public void test008_staleMissingParent2() throws Exception { // p1 does not have parent IProject p1 = createExisting("t008-p1"); waitForJobsToComplete(); // update p1 to have p3 parent InputStream contents = p1.getFile("pom_updated.xml").getContents(); p1.getFile("pom.xml").setContents(contents, IResource.FORCE, monitor); contents.close(); waitForJobsToComplete(); events.clear(); IProject p2 = createExisting("t008-p2"); waitForJobsToComplete(); assertEquals(1, events.size()); MavenProjectChangedEvent event = events.get(0); assertEquals(p2.getFile(IMavenConstants.POM_FILE_NAME), event.getSource()); assertEquals(MavenProjectChangedEvent.KIND_ADDED, event.getKind()); }
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()); }
@Override public void mavenProjectChanged(MavenProjectChangedEvent event, IProgressMonitor monitor) throws CoreException { IPreferenceStore store = Activator.getDefault().getPreferenceStore(); boolean configureGWT = store.getBoolean(Activator.CONFIGURE_GWT); if (configureGWT) { Plugin newConfig = event.getMavenProject().getMavenProject().getPlugin(GWT_WAR_MAVEN_PLUGIN_KEY); if (newConfig != null) { IJavaProject javaProject = JavaCore.create(event.getMavenProject().getProject()); if (javaProject.exists()) { List<String> modNames = findModules(newConfig, javaProject); try { GWTProjectProperties.setEntryPointModules( event.getMavenProject().getProject(), modNames); } catch (BackingStoreException e) { logError("Exception in Maven GWT Configurator, cannot set entry point modules", e); } } } } }
@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); }