Search in sources :

Example 6 with PomIO

use of org.commonjava.maven.ext.io.PomIO in project pom-manipulation-ext by release-engineering.

the class ProjectInheritanceTest method testVerifyInheritanceReversedMultiple.

@Test
public void testVerifyInheritanceReversedMultiple() throws Exception {
    // Locate the PME project pom file. Use that to verify inheritance tracking.
    final File projectroot = new File(TestUtils.resolveFileResource(RESOURCE_BASE, "").getParentFile().getParentFile().getParentFile().getParentFile(), "integration-test/src/it/project-inheritance/pom.xml");
    PomIO pomIO = new PomIO();
    List<Project> projects = pomIO.parseProject(projectroot);
    for (int i = 0; i <= 3; i++) {
        if (i == 0) {
            // First project should be root
            assertTrue(projects.get(i).getProjectParent() == null);
            assertTrue(projects.get(i).getPom().equals(projectroot));
            assertTrue(projects.get(i).getReverseInheritedList().size() == 1);
        } else if (i == 1) {
            List<Project> inherited = projects.get(i).getReverseInheritedList();
            assertTrue(inherited.size() == 2);
            assertTrue(inherited.get(0).getProjectParent().getPom().equals(projectroot));
        } else if (i == 2) {
            List<Project> inherited = projects.get(i).getReverseInheritedList();
            assertTrue(inherited.size() == 3);
            assertTrue(inherited.get(2).getPom().equals(projectroot));
        }
    }
}
Also used : Project(org.commonjava.maven.ext.common.model.Project) List(java.util.List) File(java.io.File) PomIO(org.commonjava.maven.ext.io.PomIO) Test(org.junit.Test)

Example 7 with PomIO

use of org.commonjava.maven.ext.io.PomIO in project pom-manipulation-ext by release-engineering.

the class ProjectInheritanceTest method testVerifyProjectVersion.

@Test
public void testVerifyProjectVersion() throws Exception {
    final ManipulationSession session = new ManipulationSession();
    final File projectroot = new File(TestUtils.resolveFileResource(RESOURCE_BASE, "").getParentFile().getParentFile().getParentFile().getParentFile(), "integration-test/src/it/project-inheritance/pom.xml");
    PomIO pomIO = new PomIO();
    List<Project> projects = pomIO.parseProject(projectroot);
    for (Project p : projects) {
        if (p.getPom().equals(projectroot)) {
            HashMap<ArtifactRef, Dependency> deps = p.getResolvedManagedDependencies(session);
            for (ArtifactRef a : deps.keySet()) {
                assertFalse(a.getVersionString().contains("project.version"));
            }
            deps = p.getResolvedDependencies(session);
            assertTrue(deps.size() == 1);
            for (ArtifactRef a : deps.keySet()) {
                assertFalse(a.getVersionString().contains("project.version"));
            }
            assertFalse(deps.containsKey("org.mockito:mockito-all:jar:*"));
            deps = p.getAllResolvedDependencies(session);
            assertTrue(deps.size() == 3);
            for (ArtifactRef a : deps.keySet()) {
                assertFalse(a.getVersionString().contains("project.version"));
                if (a.getGroupId().equals("org.mockito")) {
                    assertTrue(a.getVersionString().contains("*"));
                }
            }
            assertTrue(deps.containsKey(SimpleArtifactRef.parse("org.mockito:mockito-all:jar:*")));
        }
    }
}
Also used : Project(org.commonjava.maven.ext.common.model.Project) ManipulationSession(org.commonjava.maven.ext.core.ManipulationSession) Dependency(org.apache.maven.model.Dependency) File(java.io.File) PomIO(org.commonjava.maven.ext.io.PomIO) SimpleArtifactRef(org.commonjava.maven.atlas.ident.ref.SimpleArtifactRef) ArtifactRef(org.commonjava.maven.atlas.ident.ref.ArtifactRef) Test(org.junit.Test)

Example 8 with PomIO

use of org.commonjava.maven.ext.io.PomIO in project pom-manipulation-ext by release-engineering.

the class ProjectInheritanceTest method testVerifyRelativeExecutionRoot.

@Test
public void testVerifyRelativeExecutionRoot() throws Exception {
    final File projectRoot = new File(System.getProperty("user.dir") + "/pom.xml");
    Path root = Paths.get(projectRoot.getParent());
    Path absolute = Paths.get(projectRoot.toString());
    Path relative = root.relativize(absolute);
    PomIO pomIO = new PomIO();
    List<Project> projects = pomIO.parseProject(relative.toFile());
    assertTrue(projects.size() == 1);
    assertTrue(projects.get(0).isExecutionRoot());
}
Also used : Path(java.nio.file.Path) Project(org.commonjava.maven.ext.common.model.Project) File(java.io.File) PomIO(org.commonjava.maven.ext.io.PomIO) Test(org.junit.Test)

Aggregations

File (java.io.File)8 PomIO (org.commonjava.maven.ext.io.PomIO)8 Project (org.commonjava.maven.ext.common.model.Project)7 Test (org.junit.Test)7 ManipulationSession (org.commonjava.maven.ext.core.ManipulationSession)3 List (java.util.List)2 ArtifactRef (org.commonjava.maven.atlas.ident.ref.ArtifactRef)2 Path (java.nio.file.Path)1 ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)1 MavenArtifactRepository (org.apache.maven.artifact.repository.MavenArtifactRepository)1 DefaultMavenExecutionRequest (org.apache.maven.execution.DefaultMavenExecutionRequest)1 DefaultMavenExecutionResult (org.apache.maven.execution.DefaultMavenExecutionResult)1 MavenExecutionRequest (org.apache.maven.execution.MavenExecutionRequest)1 MavenExecutionRequestPopulationException (org.apache.maven.execution.MavenExecutionRequestPopulationException)1 MavenExecutionRequestPopulator (org.apache.maven.execution.MavenExecutionRequestPopulator)1 MavenSession (org.apache.maven.execution.MavenSession)1 Dependency (org.apache.maven.model.Dependency)1 SettingsBuildingException (org.apache.maven.settings.building.SettingsBuildingException)1 DefaultPlexusContainer (org.codehaus.plexus.DefaultPlexusContainer)1 PlexusContainer (org.codehaus.plexus.PlexusContainer)1