use of org.eclipse.che.plugin.maven.server.core.project.MavenProject in project che by eclipse.
the class MavenProjectManagerTest method testNotValidResolveProject.
@Test
public void testNotValidResolveProject() throws Exception {
when(project.getFile(MavenConstants.POM_FILE_NAME)).thenReturn(pom);
when(pom.getLocation()).thenReturn(new Path(MavenProjectManagerTest.class.getResource("/BadProject/pom.xml").getFile()));
when(pom.getFullPath()).thenReturn(new Path("/BadProject/pom.xml"));
when(project.getFullPath()).thenReturn(new Path("/BadProject"));
projectManager.addListener(listener);
MavenProject mavenProject = new MavenProject(project, workspace);
mavenProject.read(project, manager);
MavenKey mavenKey = mavenProject.getMavenKey();
assertThat(mavenKey).isNotNull();
projectManager.resolveMavenProject(project, mavenProject);
verify(listener).projectResolved(any(), any());
assertThat(mavenProject.getProblems()).isNotNull().isNotEmpty();
mavenProject.getProblems().forEach(System.out::println);
}
use of org.eclipse.che.plugin.maven.server.core.project.MavenProject in project che by eclipse.
the class MavenWebSocketCommunication method sendUpdateMassage.
@Override
public void sendUpdateMassage(Set<MavenProject> updated, List<MavenProject> removed) {
ProjectsUpdateMessage dto = DtoFactory.newDto(ProjectsUpdateMessage.class);
List<String> updatedPaths = updated.stream().map(project -> project.getProject().getFullPath().toOSString()).collect(Collectors.toList());
dto.setUpdatedProjects(updatedPaths);
List<String> removedPaths = removed.stream().map(project -> project.getProject().getFullPath().toOSString()).collect(Collectors.toList());
dto.setDeletedProjects(removedPaths);
send(DtoFactory.getInstance().toJsonElement(dto).getAsJsonObject(), MessageType.UPDATE);
}
use of org.eclipse.che.plugin.maven.server.core.project.MavenProject in project che by eclipse.
the class MavenWorkspace method runResolve.
private void runResolve() {
//TODO synchronise on projectsToResolve change
Set<MavenProject> needResolve = new HashSet<>(projectsToResolve);
projectsToResolve.clear();
for (MavenProject mavenProject : needResolve) {
resolveExecutor.submitTask(new MavenProjectResolveTask(mavenProject, manager, () -> {
addSourcesFromBuildHelperPlugin(mavenProject);
classpathManager.updateClasspath(mavenProject);
}));
}
}
use of org.eclipse.che.plugin.maven.server.core.project.MavenProject in project che by eclipse.
the class MavenWorkspace method updateJavaProject.
private void updateJavaProject(MavenProject project) {
IJavaProject javaProject = JavaCore.create(project.getProject());
try {
ClasspathHelper helper = new ClasspathHelper(javaProject);
project.getSources().stream().map(s -> project.getProject().getFullPath().append(s)).forEach(helper::addSourceEntry);
project.getTestSources().stream().map(s -> project.getProject().getFullPath().append(s)).forEach(helper::addSourceEntry);
//add maven classpath container
helper.addContainerEntry(new Path(MavenClasspathContainer.CONTAINER_ID));
//add JRE classpath container
helper.addContainerEntry(new Path(JREContainerInitializer.JRE_CONTAINER));
javaProject.setRawClasspath(helper.getEntries(), null);
} catch (JavaModelException e) {
LOG.error("Can't update Java project classpath", e);
}
}
use of org.eclipse.che.plugin.maven.server.core.project.MavenProject in project che by eclipse.
the class WorkspaceTest method testImportMultimoduleProjectDeleteAndImportAgain.
@Test
public void testImportMultimoduleProjectDeleteAndImportAgain() throws Exception {
String pom = "<groupId>com.codenvy.workspacebf11inh2ze5i06bk</groupId>\n" + "<artifactId>multimodule</artifactId>\n" + " <packaging>pom</packaging>\n" + " <version>1.0-SNAPSHOT</version>\n" + " <properties>\n" + " <maven.compiler.source>1.6</maven.compiler.source>\n" + " <maven.compiler.target>1.6</maven.compiler.target>\n" + " </properties>\n" + " <modules>\n" + " <module>my-lib</module>\n" + " <module>my-webapp</module>\n" + " </modules>";
createTestProject("parent", pom);
String myLibPom = " <parent>\n" + "<groupId>com.codenvy.workspacebf11inh2ze5i06bk</groupId>\n" + "<artifactId>multimodule</artifactId>\n" + " <version>1.0-SNAPSHOT</version>\n" + " </parent>\n" + " <artifactId>my-lib</artifactId>\n" + " <version>1.0-SNAPSHOT</version>\n" + " <packaging>jar</packaging>\n" + "\n" + " <name>sample-lib</name>\n" + "\n" + " <properties>\n" + " <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\n" + " </properties>\n" + "\n" + " <dependencies>\n" + " <dependency>\n" + " <groupId>junit</groupId>\n" + " <artifactId>junit</artifactId>\n" + " <version>3.8.1</version>\n" + " <scope>test</scope>\n" + " </dependency>\n" + " </dependencies>";
createTestProject("parent/my-lib", myLibPom);
String myWebApp = " <parent>\n" + "<groupId>com.codenvy.workspacebf11inh2ze5i06bk</groupId>\n" + "<artifactId>multimodule</artifactId>\n" + " <version>1.0-SNAPSHOT</version>\n" + " </parent>\n" + " <artifactId>my-webapp</artifactId>\n" + " <packaging>war</packaging>\n" + " <version>1.0</version>\n" + " <name>SpringDemo</name>\n" + " <properties>\n" + " <maven.compiler.source>1.8</maven.compiler.source>\n" + " <maven.compiler.target>1.8</maven.compiler.target>\n" + " </properties>\n" + " <dependencies>\n" + " <dependency>\n" + "<groupId>com.codenvy.workspacebf11inh2ze5i06bk</groupId>\n" + " <artifactId>my-lib</artifactId>\n" + " <version>1.0-SNAPSHOT</version>\n" + " </dependency>\n" + " <dependency>\n" + " <groupId>javax.servlet</groupId>\n" + " <artifactId>servlet-api</artifactId>\n" + " <version>2.5</version>\n" + " <scope>provided</scope>\n" + " </dependency>\n" + " <dependency>\n" + " <groupId>org.springframework</groupId>\n" + " <artifactId>spring-webmvc</artifactId>\n" + " <version>3.0.5.RELEASE</version>\n" + " </dependency>\n" + " <dependency>\n" + " <groupId>junit</groupId>\n" + " <artifactId>junit</artifactId>\n" + " <version>3.8.1</version>\n" + " <scope>test</scope>\n" + " </dependency>\n" + " </dependencies>\n" + " <build>\n" + " <finalName>greeting</finalName>\n" + " </build>";
createTestProject("parent/my-webapp", myWebApp);
IProject test = ResourcesPlugin.getWorkspace().getRoot().getProject("parent");
mavenWorkspace.update(Collections.singletonList(test));
mavenWorkspace.waitForUpdate();
MavenProject mavenProject = mavenProjectManager.findMavenProject(test);
assertThat(mavenProject).isNotNull();
pm.delete("parent");
createTestProject("parent2", pom);
createTestProject("parent2/my-lib", myLibPom);
createTestProject("parent2/my-webapp", myWebApp);
IProject test2 = ResourcesPlugin.getWorkspace().getRoot().getProject("parent2");
mavenWorkspace.update(Collections.singletonList(test2));
mavenWorkspace.waitForUpdate();
MavenProject mavenProject2 = mavenProjectManager.findMavenProject(test2);
assertThat(mavenProject2).isNotNull();
}
Aggregations