Search in sources :

Example 1 with ProjectPom

use of aQute.bnd.maven.support.ProjectPom in project bnd by bndtools.

the class Project method doMavenPom.

/**
	 * The user selected pom in a path. This will place the pom as well as its
	 * dependencies on the list
	 *
	 * @param strategyx the strategy to use.
	 * @param result The list of result containers
	 * @throws Exception anything goes wrong
	 */
public void doMavenPom(Strategy strategyx, List<Container> result, String action) throws Exception {
    File pomFile = getFile("pom.xml");
    if (!pomFile.isFile())
        msgs.MissingPom();
    else {
        ProjectPom pom = getWorkspace().getMaven().createProjectModel(pomFile);
        if (action == null)
            action = "compile";
        Pom.Scope act = Pom.Scope.valueOf(action);
        Set<Pom> dependencies = pom.getDependencies(act);
        for (Pom sub : dependencies) {
            File artifact = sub.getArtifact();
            Container container = new Container(artifact, null);
            result.add(container);
        }
    }
}
Also used : ProjectPom(aQute.bnd.maven.support.ProjectPom) File(java.io.File) ProjectPom(aQute.bnd.maven.support.ProjectPom) Pom(aQute.bnd.maven.support.Pom)

Example 2 with ProjectPom

use of aQute.bnd.maven.support.ProjectPom in project bnd by bndtools.

the class MavenTest method testProjectPom.

/**
	 * Test parsing a project pom
	 * 
	 * @throws Exception
	 */
public static void testProjectPom() throws Exception {
    Maven maven = new Maven(null);
    ProjectPom pom = maven.createProjectModel(IO.getFile(cwd, "testresources/ws/maven1/testpom.xml"));
    assertEquals("artifact", pom.getArtifactId());
    assertEquals("group-parent", pom.getGroupId());
    assertEquals("1.0.0", pom.getVersion());
    assertEquals("Artifact", pom.getName());
    assertEquals("Parent Description\n\nDescription artifact", pom.getDescription());
    List<Dependency> dependencies = pom.getDependencies();
    // dep1
    boolean dep1 = false;
    // artifact (after macro)
    boolean dep2 = false;
    // junit
    boolean dep3 = false;
    // easymock
    boolean dep4 = false;
    for (Dependency dep : dependencies) {
        String artifactId = dep.getArtifactId();
        if ("dep1".equals(artifactId)) {
            assertFalse(dep1);
            dep1 = true;
            assertEquals("xyz", dep.getGroupId());
            assertEquals("1.0.1", dep.getVersion());
            assertEquals(Pom.Scope.valueOf("compile"), dep.getScope());
        } else if ("artifact".equals(artifactId)) {
            assertFalse(dep2);
            dep2 = true;
            assertEquals("group-parent", dep.getGroupId());
            assertEquals("1.0.2", dep.getVersion());
            assertEquals(Pom.Scope.valueOf("compile"), dep.getScope());
        } else if ("junit".equals(artifactId)) {
            assertFalse(dep3);
            dep3 = true;
            assertEquals("junit", dep.getGroupId());
            assertEquals("4.0", dep.getVersion());
            assertEquals(Pom.Scope.valueOf("test"), dep.getScope());
        } else if ("easymock".equals(artifactId)) {
            assertFalse(dep4);
            dep4 = true;
            assertEquals("org.easymock", dep.getGroupId());
            assertEquals("2.4", dep.getVersion());
            assertEquals(Pom.Scope.valueOf("compile"), dep.getScope());
        } else
            fail("'" + artifactId + "'");
    }
    assertTrue(dep1 && dep2 && dep3 && dep4);
    assertEquals("aa", pom.getProperty("a"));
    assertEquals("b from parent", pom.getProperty("b"));
    assertEquals("aab from parentartifact", pom.getProperty("c"));
}
Also used : Maven(aQute.bnd.maven.support.Maven) ProjectPom(aQute.bnd.maven.support.ProjectPom) Dependency(aQute.bnd.maven.support.Pom.Dependency)

Aggregations

ProjectPom (aQute.bnd.maven.support.ProjectPom)2 Maven (aQute.bnd.maven.support.Maven)1 Pom (aQute.bnd.maven.support.Pom)1 Dependency (aQute.bnd.maven.support.Pom.Dependency)1 File (java.io.File)1