use of org.apache.maven.execution.MavenExecutionResult in project tycho by eclipse.
the class BuildQualifierTest method getProject.
private MavenProject getProject(String baseDir, String pom) throws Exception {
File basedirFile = getBasedir(baseDir);
File pomFile = new File(basedirFile, pom);
MavenExecutionRequest request = newMavenExecutionRequest(pomFile);
request.getProjectBuildingRequest().setProcessPlugins(false);
MavenExecutionResult result = maven.execute(request);
return result.getProject();
}
use of org.apache.maven.execution.MavenExecutionResult in project build-info by JFrogDev.
the class BuildInfoRecorderLifecycleParticipantTest method testParticipantImplementation.
public void testParticipantImplementation() throws Exception {
BuildInfoRecorder buildInfoRecorder = new BuildInfoRecorder();
BuildInfoRecorderLifecycleParticipant participant = new BuildInfoRecorderLifecycleParticipant();
Class<BuildInfoRecorderLifecycleParticipant> participantClass = BuildInfoRecorderLifecycleParticipant.class;
Field recorderField = participantClass.getDeclaredField("recorder");
recorderField.set(participant, buildInfoRecorder);
Field loggerField = participantClass.getDeclaredField("logger");
loggerField.setAccessible(true);
loggerField.set(participant, new AbstractLogger(1, "dummy") {
public void debug(String message, Throwable throwable) {
Assert.assertTrue(message.contains("value is true"));
}
public void info(String message, Throwable throwable) {
assert false;
}
public void warn(String message, Throwable throwable) {
assert false;
}
public void error(String message, Throwable throwable) {
assert false;
}
public void fatalError(String message, Throwable throwable) {
assert false;
}
public Logger getChildLogger(String name) {
assert false;
return null;
}
});
PlexusContainer plexusContainerMock = EasyMock.createMock(PlexusContainer.class);
RepositorySystemSession repositorySystemSession = EasyMock.createMock(RepositorySystemSession.class);
MavenExecutionRequest requestMock = EasyMock.createMock(MavenExecutionRequest.class);
Properties mockSessionProperties = new Properties();
mockSessionProperties.setProperty(BuildInfoConfigProperties.ACTIVATE_RECORDER, "true");
EasyMock.expect(requestMock.getSystemProperties()).andReturn(mockSessionProperties).once();
EasyMock.expect(requestMock.getUserProperties()).andReturn(mockSessionProperties).once();
AbstractExecutionListener existingListener = new AbstractExecutionListener();
EasyMock.expect(requestMock.getExecutionListener()).andReturn(existingListener).times(1);
EasyMock.expect(requestMock.getUserSettingsFile()).andReturn(null).once();
EasyMock.expect(requestMock.setExecutionListener(buildInfoRecorder)).andReturn(null).once();
EasyMock.replay(requestMock);
MavenExecutionResult resultMock = EasyMock.createMock(MavenExecutionResult.class);
MavenSession session = new MavenSession(plexusContainerMock, repositorySystemSession, requestMock, resultMock);
// value is true
participant.afterProjectsRead(session);
}
use of org.apache.maven.execution.MavenExecutionResult in project tycho by eclipse.
the class DependencyComputerTest method testTYCHO0378unwantedSelfDependency.
@Test
public void testTYCHO0378unwantedSelfDependency() throws Exception {
File basedir = getBasedir("projects/TYCHO0378unwantedSelfDependency");
File pom = new File(basedir, "pom.xml");
MavenExecutionRequest request = newMavenExecutionRequest(pom);
request.getProjectBuildingRequest().setProcessPlugins(false);
MavenExecutionResult result = maven.execute(request);
Assert.assertEquals(0, result.getProject().getDependencies().size());
}
use of org.apache.maven.execution.MavenExecutionResult in project tycho by eclipse.
the class AbstractTychoMojoTestCase method getSortedProjects.
protected List<MavenProject> getSortedProjects(File basedir, Properties userProperties, File platform) throws Exception {
File pom = new File(basedir, "pom.xml");
MavenExecutionRequest request = newMavenExecutionRequest(pom);
request.getProjectBuildingRequest().setProcessPlugins(false);
request.setLocalRepository(getLocalRepository());
if (platform != null) {
request.getUserProperties().put("tycho.targetPlatform", platform.getAbsolutePath());
}
if (userProperties != null) {
request.getUserProperties().putAll(userProperties);
}
MavenExecutionResult result = maven.execute(request);
if (result.hasExceptions()) {
throw new CompoundRuntimeException(result.getExceptions());
}
return result.getTopologicallySortedProjects();
}
use of org.apache.maven.execution.MavenExecutionResult in project tycho by eclipse.
the class AbstractTychoMojoTestCase method newMavenSession.
protected MavenSession newMavenSession(MavenProject project, List<MavenProject> projects) throws Exception {
MavenExecutionRequest request = newMavenExecutionRequest(new File(project.getBasedir(), "pom.xml"));
MavenExecutionResult result = new DefaultMavenExecutionResult();
DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession();
MavenSession session = new MavenSession(getContainer(), repositorySession, request, result);
session.setProjects(projects);
session.setCurrentProject(project);
return session;
}
Aggregations