use of org.apache.maven.execution.MavenSession in project tycho by eclipse.
the class BuildQualifierTest method testAggregateAttachedFeatureQualifier.
public void testAggregateAttachedFeatureQualifier() throws Exception {
File basedir = getBasedir("projects/stablebuildqualifier/attachedfeature");
List<MavenProject> projects = getSortedProjects(basedir, new File(basedir, "targetplatform"));
MavenProject project = getProject(projects, "attachedfeature");
ReactorProject reactorProject = DefaultReactorProject.adapt(project);
DefaultDependencyArtifacts dependencyArtifacts = (DefaultDependencyArtifacts) TychoProjectUtils.getDependencyArtifacts(project);
// replace target platform dependencies with fake attached feature and bundle atrifacts
ArtifactDescriptor attachedFeature = dependencyArtifacts.getArtifact(ArtifactType.TYPE_ECLIPSE_FEATURE, "attachedfeature.attached.feature", null);
dependencyArtifacts.removeAll(attachedFeature.getKey().getType(), attachedFeature.getKey().getId());
dependencyArtifacts.addReactorArtifact(attachedFeature.getKey(), reactorProject, "attached-feature", attachedFeature.getInstallableUnits());
ArtifactDescriptor attachedBundle = dependencyArtifacts.getArtifact(ArtifactType.TYPE_ECLIPSE_PLUGIN, "attachedfeature.attached.bundle", null);
dependencyArtifacts.removeAll(attachedBundle.getKey().getType(), attachedBundle.getKey().getId());
dependencyArtifacts.addReactorArtifact(attachedBundle.getKey(), reactorProject, "attached-bundle", attachedBundle.getInstallableUnits());
MavenSession session = newMavenSession(projects.get(0), projects);
executeMojo(session, project, "build-qualifier-aggregator");
assertQualifier("201206180600", projects, "attachedfeature");
}
use of org.apache.maven.execution.MavenSession 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.MavenSession in project pom-manipulation-ext by release-engineering.
the class VersioningCalculatorTest method setupSession.
private VersioningState setupSession(final Properties properties, final Map<ProjectRef, String[]> versionMap) throws Exception {
final ArtifactRepository ar = new MavenArtifactRepository("test", "http://repo.maven.apache.org/maven2", new DefaultRepositoryLayout(), new ArtifactRepositoryPolicy(), new ArtifactRepositoryPolicy());
final MavenExecutionRequest req = new DefaultMavenExecutionRequest().setUserProperties(properties).setRemoteRepositories(Arrays.asList(ar));
final PlexusContainer container = new DefaultPlexusContainer();
final MavenSession mavenSession = new MavenSession(container, null, req, new DefaultMavenExecutionResult());
session = new ManipulationSession();
session.setMavenSession(mavenSession);
final VersioningState state = new VersioningState(properties);
session.setState(state);
final Map<String, byte[]> dataMap = new HashMap<>();
if (versionMap != null && !versionMap.isEmpty()) {
for (final Map.Entry<ProjectRef, String[]> entry : versionMap.entrySet()) {
final String path = toMetadataPath(entry.getKey());
final byte[] data = setupMetadataVersions(entry.getValue());
dataMap.put(path, data);
}
}
final Location mdLoc = MavenLocationExpander.EXPANSION_TARGET;
final Transport mdTrans = new StubTransport(dataMap);
modder = new TestVersionCalculator(new ManipulationSession(), mdLoc, mdTrans, temp.newFolder("galley-cache"));
return state;
}
use of org.apache.maven.execution.MavenSession in project pom-manipulation-ext by release-engineering.
the class CliTest method checkLocalRepositoryWithExplicitMavenRepo.
@Test
public void checkLocalRepositoryWithExplicitMavenRepo() throws Exception {
File folder = temp.newFolder();
Cli c = new Cli();
executeMethod(c, "run", new Object[] { new String[] { "-Dmaven.repo.local=" + folder.toString() } });
ManipulationSession session = (ManipulationSession) FieldUtils.readField(c, "session", true);
MavenSession ms = (MavenSession) FieldUtils.readField(session, "mavenSession", true);
assertTrue(ms.getRequest().getLocalRepository().getBasedir().equals(ms.getRequest().getLocalRepositoryPath().toString()));
}
use of org.apache.maven.execution.MavenSession in project pom-manipulation-ext by release-engineering.
the class CliTest method checkLocalRepositoryWithDefaults.
@Test
public void checkLocalRepositoryWithDefaults() throws Exception {
Cli c = new Cli();
File settings = writeSettings(temp.newFile());
executeMethod(c, "run", new Object[] { new String[] { "-s", settings.toString() } });
ManipulationSession session = (ManipulationSession) FieldUtils.readField(c, "session", true);
MavenSession ms = (MavenSession) FieldUtils.readField(session, "mavenSession", true);
assertTrue(ms.getRequest().getLocalRepository().getBasedir().equals(ms.getRequest().getLocalRepositoryPath().toString()));
assertTrue("File " + new File(ms.getRequest().getLocalRepository().getBasedir()).getParentFile().toString() + " was not equal to " + System.getProperty("user.home") + File.separatorChar + ".m2", new File(ms.getRequest().getLocalRepository().getBasedir()).getParentFile().toString().equals(System.getProperty("user.home") + File.separatorChar + ".m2"));
}
Aggregations