use of org.apache.maven.execution.MavenExecutionRequest 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.MavenExecutionRequest 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.MavenExecutionRequest 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.MavenExecutionRequest in project maven-archetype by apache.
the class RemoteCatalogArchetypeDataSource method getAuthenticationInfo.
private AuthenticationInfo getAuthenticationInfo(String id) {
MavenSession session = legacySupport.getSession();
if (session != null && id != null) {
MavenExecutionRequest request = session.getRequest();
if (request != null) {
List<Server> servers = request.getServers();
if (servers != null) {
for (Server server : servers) {
if (id.equalsIgnoreCase(server.getId())) {
SettingsDecryptionResult result = settingsDecrypter.decrypt(new DefaultSettingsDecryptionRequest(server));
server = result.getServer();
AuthenticationInfo authInfo = new AuthenticationInfo();
authInfo.setUserName(server.getUsername());
authInfo.setPassword(server.getPassword());
authInfo.setPrivateKey(server.getPrivateKey());
authInfo.setPassphrase(server.getPassphrase());
return authInfo;
}
}
}
}
}
// empty one to prevent NPE
return new AuthenticationInfo();
}
use of org.apache.maven.execution.MavenExecutionRequest in project maven-archetype by apache.
the class RemoteCatalogArchetypeDataSource method getMirror.
private Mirror getMirror(String repoId) {
MavenSession session = legacySupport.getSession();
MavenExecutionRequest request = session.getRequest();
if (request != null) {
return getMirror(repoId, request.getMirrors());
}
return null;
}
Aggregations