Search in sources :

Example 1 with MavenProjectInfo

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()));
}
Also used : MavenServerResult(org.eclipse.che.maven.server.MavenServerResult) MavenModel(org.eclipse.che.maven.data.MavenModel) MavenProjectInfo(org.eclipse.che.maven.server.MavenProjectInfo) File(java.io.File) Test(org.testng.annotations.Test)

Example 2 with MavenProjectInfo

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);
}
Also used : MavenServerResult(org.eclipse.che.maven.server.MavenServerResult) MavenModel(org.eclipse.che.maven.data.MavenModel) MavenProjectInfo(org.eclipse.che.maven.server.MavenProjectInfo) File(java.io.File) Test(org.testng.annotations.Test)

Example 3 with MavenProjectInfo

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());
}
Also used : MavenServerResult(org.eclipse.che.maven.server.MavenServerResult) MavenModel(org.eclipse.che.maven.data.MavenModel) MavenProjectInfo(org.eclipse.che.maven.server.MavenProjectInfo) File(java.io.File) MavenArtifact(org.eclipse.che.maven.data.MavenArtifact) Test(org.testng.annotations.Test)

Example 4 with MavenProjectInfo

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;
    }
}
Also used : MavenServerResult(org.eclipse.che.maven.server.MavenServerResult) MavenProjectInfo(org.eclipse.che.maven.server.MavenProjectInfo)

Example 5 with MavenProjectInfo

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();
}
Also used : MavenServerResult(org.eclipse.che.maven.server.MavenServerResult) MavenModel(org.eclipse.che.maven.data.MavenModel) MavenProjectInfo(org.eclipse.che.maven.server.MavenProjectInfo) File(java.io.File) Test(org.testng.annotations.Test)

Aggregations

MavenProjectInfo (org.eclipse.che.maven.server.MavenProjectInfo)5 MavenServerResult (org.eclipse.che.maven.server.MavenServerResult)5 File (java.io.File)4 MavenModel (org.eclipse.che.maven.data.MavenModel)4 Test (org.testng.annotations.Test)4 MavenArtifact (org.eclipse.che.maven.data.MavenArtifact)1