use of org.eclipse.che.maven.server.MavenProjectInfo in project che by eclipse.
the class MavenServerManagerTest method testMultimoduleProjectModuleHasDependencyOnAnotherModule.
@Test
public void testMultimoduleProjectModuleHasDependencyOnAnotherModule() throws Exception {
MavenServerResult resolveProject = mavenServer.resolveProject(new File(MavenServerManagerTest.class.getResource("/multimoduleProject/test/pom.xml").getFile()), Collections.emptyList(), Collections.emptyList());
assertNotNull(resolveProject);
MavenProjectInfo projectInfo = resolveProject.getProjectInfo();
assertNotNull(projectInfo);
MavenModel mavenModel = projectInfo.getMavenModel();
assertNotNull(mavenModel);
assertThat(mavenModel.getPackaging()).isEqualTo("jar");
assertThat(mavenModel.getModules()).isEmpty();
assertThat(mavenModel.getDependencies()).isNotEmpty().hasSize(6);
mavenModel.getDependencies().forEach(mavenArtifact -> System.out.println(mavenArtifact.getFile().getAbsolutePath()));
}
use of org.eclipse.che.maven.server.MavenProjectInfo in project che by eclipse.
the class MavenServerManagerTest method testResolveMultimoduleProjectModulePom.
@Test
public void testResolveMultimoduleProjectModulePom() throws Exception {
MavenServerResult resolveProject = mavenServer.resolveProject(new File(MavenServerManagerTest.class.getResource("/multimoduleProject/subModule/pom.xml").getFile()), Collections.emptyList(), Collections.emptyList());
assertNotNull(resolveProject);
MavenProjectInfo projectInfo = resolveProject.getProjectInfo();
assertNotNull(projectInfo);
MavenModel mavenModel = projectInfo.getMavenModel();
assertNotNull(mavenModel);
assertThat(mavenModel.getPackaging()).isEqualTo("jar");
assertThat(mavenModel.getModules()).isEmpty();
assertThat(mavenModel.getDependencies()).isNotEmpty().hasSize(3);
}
use of org.eclipse.che.maven.server.MavenProjectInfo in project che by eclipse.
the class MavenServerManagerTest method testProjectHasDependencies.
@Test
public void testProjectHasDependencies() throws Exception {
MavenServerResult resolveProject = mavenServer.resolveProject(new File(MavenServerManagerTest.class.getResource("/FirstProject/pom.xml").getFile()), Collections.emptyList(), Collections.emptyList());
assertNotNull(resolveProject);
MavenProjectInfo projectInfo = resolveProject.getProjectInfo();
assertNotNull(projectInfo);
MavenModel mavenModel = projectInfo.getMavenModel();
assertNotNull(mavenModel);
List<MavenArtifact> dependencies = mavenModel.getDependencies();
assertFalse(dependencies.isEmpty());
assertEquals(26, dependencies.size());
}
use of org.eclipse.che.maven.server.MavenProjectInfo in project che by eclipse.
the class MavenModelReader method resolveMavenProject.
public MavenModelReaderResult resolveMavenProject(File pom, MavenServerWrapper mavenServer, List<String> activeProfiles, List<String> inactiveProfiles, MavenServerManager serverManager) {
try {
MavenServerResult resolveProject = mavenServer.resolveProject(pom, activeProfiles, inactiveProfiles);
MavenProjectInfo projectInfo = resolveProject.getProjectInfo();
if (projectInfo != null) {
return new MavenModelReaderResult(projectInfo.getMavenModel(), projectInfo.getActiveProfiles(), Collections.emptyList(), resolveProject.getProblems(), resolveProject.getUnresolvedArtifacts());
} else {
MavenModelReaderResult readMavenProject = readMavenProject(pom, serverManager);
readMavenProject.getProblems().addAll(resolveProject.getProblems());
readMavenProject.getUnresolvedArtifacts().addAll(resolveProject.getUnresolvedArtifacts());
return readMavenProject;
}
} catch (Throwable t) {
String message = t.getMessage();
LOG.info(message, t);
MavenModelReaderResult readMavenProject = readMavenProject(pom, serverManager);
if (message != null) {
readMavenProject.getProblems().add(MavenProjectProblem.newStructureProblem(pom.getPath(), message));
} else {
readMavenProject.getProblems().add(MavenProjectProblem.newSyntaxProblem(pom.getPath(), MavenProblemType.SYNTAX));
}
return readMavenProject;
}
}
use of org.eclipse.che.maven.server.MavenProjectInfo in project che by eclipse.
the class MavenServerManagerTest method testResolveMultimoduleProjectMainPom.
@Test
public void testResolveMultimoduleProjectMainPom() throws Exception {
MavenServerResult resolveProject = mavenServer.resolveProject(new File(MavenServerManagerTest.class.getResource("/multimoduleProject/pom.xml").getFile()), Collections.emptyList(), Collections.emptyList());
assertNotNull(resolveProject);
MavenProjectInfo projectInfo = resolveProject.getProjectInfo();
assertNotNull(projectInfo);
MavenModel mavenModel = projectInfo.getMavenModel();
assertNotNull(mavenModel);
assertThat(mavenModel.getPackaging()).isEqualTo("pom");
assertThat(mavenModel.getModules()).containsExactly("subModule", "test");
assertThat(mavenModel.getDependencies()).isEmpty();
}
Aggregations