use of org.commonjava.maven.ext.io.PomIO in project pom-manipulation-ext by release-engineering.
the class ProjectInheritanceTest method testVerifyExecutionRoot.
@Test
public void testVerifyExecutionRoot() 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/common/pom.xml");
PomIO pomIO = new PomIO();
List<Project> projects = pomIO.parseProject(projectroot);
for (Project p : projects) {
if (p.getKey().toString().equals("io.apiman:apiman-common:1.2.7-SNAPSHOT")) {
assertTrue(p.isExecutionRoot());
assertTrue(p.isInheritanceRoot());
} else {
assertFalse(p.isExecutionRoot());
assertFalse(p.isInheritanceRoot());
}
}
}
use of org.commonjava.maven.ext.io.PomIO in project pom-manipulation-ext by release-engineering.
the class ProjectInheritanceTest method testVerifyInheritance.
@Test
public void testVerifyInheritance() 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(), "pom.xml");
PomIO pomIO = new PomIO();
List<Project> projects = pomIO.parseProject(projectroot);
for (Project p : projects) {
if (!p.getPom().equals(projectroot)) {
assertTrue(p.getProjectParent().getPom().equals(projectroot));
}
}
}
use of org.commonjava.maven.ext.io.PomIO in project pom-manipulation-ext by release-engineering.
the class Cli method createSession.
private void createSession(File target, File settings) {
try {
PlexusContainer container = new DefaultPlexusContainer();
pomIO = container.lookup(PomIO.class);
session = container.lookup(ManipulationSession.class);
manipulationManager = container.lookup(ManipulationManager.class);
final MavenExecutionRequest req = new DefaultMavenExecutionRequest().setUserProperties(System.getProperties()).setUserProperties(userProps).setRemoteRepositories(Collections.<ArtifactRepository>emptyList());
ArtifactRepository ar = null;
if (settings == null) {
// No, this is not a typo. If current default is null, supply new local and global.
// This function passes in settings to make it easier to test.
this.settings = settings = new File(System.getProperty("user.home"), ".m2/settings.xml");
ar = new MavenArtifactRepository();
ar.setUrl("file://" + System.getProperty("user.home") + "/.m2/repository");
req.setLocalRepository(ar);
}
req.setUserSettingsFile(settings);
req.setGlobalSettingsFile(settings);
MavenExecutionRequestPopulator executionRequestPopulator = container.lookup(MavenExecutionRequestPopulator.class);
executionRequestPopulator.populateFromSettings(req, parseSettings(settings));
executionRequestPopulator.populateDefaults(req);
if (ar != null) {
ar.setUrl("file://" + req.getLocalRepositoryPath());
}
if (userProps != null && userProps.containsKey("maven.repo.local")) {
if (ar == null) {
ar = new MavenArtifactRepository();
}
ar.setUrl("file://" + userProps.getProperty("maven.repo.local"));
req.setLocalRepository(ar);
}
final MavenSession mavenSession = new MavenSession(container, null, req, new DefaultMavenExecutionResult());
mavenSession.getRequest().setPom(target);
session.setMavenSession(mavenSession);
} catch (ComponentLookupException e) {
logger.debug("Caught problem instantiating ", e);
System.err.println("Unable to start Cli subsystem");
System.exit(100);
} catch (PlexusContainerException e) {
logger.debug("Caught problem instantiating ", e);
System.err.println("Unable to start Cli subsystem");
System.exit(100);
} catch (SettingsBuildingException e) {
logger.debug("Caught problem parsing settings file ", e);
System.err.println("Unable to parse settings.xml file");
System.exit(100);
} catch (MavenExecutionRequestPopulationException e) {
logger.debug("Caught problem populating maven request from settings file ", e);
System.err.println("Unable to create maven execution request from settings.xml file");
System.exit(100);
}
}
use of org.commonjava.maven.ext.io.PomIO in project pom-manipulation-ext by release-engineering.
the class ResolveArtifactTest method testResolveArtifacts.
@Test
public void testResolveArtifacts() throws Exception {
final ManipulationSession session = new ManipulationSession();
// Locate the PME project pom file.
final File projectroot = new File(TestUtils.resolveFileResource("properties/", "").getParentFile().getParentFile().getParentFile().getParentFile(), "pom.xml");
PomIO pomIO = new PomIO();
List<Project> projects = pomIO.parseProject(projectroot);
Set<ArtifactRef> artifacts = RESTCollector.establishAllDependencies(session, projects, null);
// NB If this test fails then check if PME deps/plugins have changed...
assertTrue(artifacts.size() == 59);
}
use of org.commonjava.maven.ext.io.PomIO in project pom-manipulation-ext by release-engineering.
the class ProjectInheritanceTest method testVerifyInheritanceMultiple.
@Test
public void testVerifyInheritanceMultiple() 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).getInheritedList().size() == 1);
} else if (i == 1) {
List<Project> inherited = projects.get(i).getInheritedList();
assertTrue(inherited.size() == 2);
assertTrue(inherited.get(1).getProjectParent().getPom().equals(projectroot));
} else if (i == 2) {
List<Project> inherited = projects.get(i).getInheritedList();
assertTrue(inherited.size() == 3);
assertTrue(inherited.get(0).getPom().equals(projectroot));
}
}
}
Aggregations