use of org.apache.maven.execution.MavenSession 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.MavenSession 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;
}
use of org.apache.maven.execution.MavenSession in project maven-plugins by apache.
the class AssemblyInterpolatorTest method testShouldResolveContextValueBeforeModelPropertyOrModelGroupIdInAssemblyId.
public void testShouldResolveContextValueBeforeModelPropertyOrModelGroupIdInAssemblyId() throws AssemblyInterpolationException, InvalidAssemblerConfigurationException, AssemblyReadException, IOException {
final Model model = new Model();
model.setArtifactId("artifact-id");
model.setGroupId("group.id");
model.setVersion("1");
model.setPackaging("jar");
final Properties props = new Properties();
props.setProperty("groupId", "other.id");
model.setProperties(props);
final Assembly assembly = new Assembly();
assembly.setId("assembly.${groupId}");
final EasyMockSupport mm = new EasyMockSupport();
final MavenSession session = mm.createMock(MavenSession.class);
final Properties execProps = new Properties();
execProps.setProperty("groupId", "still.another.id");
expect(session.getExecutionProperties()).andReturn(execProps).anyTimes();
expect(session.getUserProperties()).andReturn(new Properties()).anyTimes();
final PojoConfigSource cs = new PojoConfigSource();
final ArtifactRepository lr = mm.createMock(ArtifactRepository.class);
cs.setLocalRepository(lr);
cs.setMavenSession(session);
cs.setRootInterpolator(FixedStringSearchInterpolator.create());
cs.setEnvironmentInterpolator(FixedStringSearchInterpolator.create(new PropertiesBasedValueSource(execProps)));
cs.setEnvInterpolator(FixedStringSearchInterpolator.empty());
expect(lr.getBasedir()).andReturn("/path/to/local/repo").anyTimes();
mm.replayAll();
final MavenProject project = new MavenProject(model);
cs.setMavenProject(project);
final Assembly result = roundTripInterpolation(assembly, cs);
assertEquals("assembly.still.another.id", result.getId());
mm.verifyAll();
mm.resetAll();
}
use of org.apache.maven.execution.MavenSession in project maven-plugins by apache.
the class AbstractAssemblyMojo method createCommandLinePropertiesInterpolator.
private FixedStringSearchInterpolator createCommandLinePropertiesInterpolator() {
Properties commandLineProperties = System.getProperties();
final MavenSession session = getMavenSession();
if (session != null) {
commandLineProperties = new Properties();
commandLineProperties.putAll(session.getSystemProperties());
commandLineProperties.putAll(session.getUserProperties());
}
PropertiesBasedValueSource cliProps = new PropertiesBasedValueSource(commandLineProperties);
return FixedStringSearchInterpolator.create(cliProps);
}
use of org.apache.maven.execution.MavenSession in project maven-plugins by apache.
the class AssemblyFormatUtilsTest method verifyEvalFileNameMapping.
private void verifyEvalFileNameMapping(final String expression, final String classifier, final String extension, final MavenProject mainProject, final MavenProject moduleProject, final MavenProject artifactProject, final String checkValue) throws AssemblyFormattingException {
final ArtifactMock artifactMock = new ArtifactMock(mockManager, artifactProject.getGroupId(), artifactProject.getArtifactId(), artifactProject.getVersion(), extension, classifier, false, null);
final ArtifactMock moduleArtifactMock = new ArtifactMock(mockManager, moduleProject.getGroupId(), moduleProject.getArtifactId(), moduleProject.getVersion(), "jar", false, null);
final MavenSession session = mockManager.createMock(MavenSession.class);
expect(session.getExecutionProperties()).andReturn(System.getProperties()).anyTimes();
expect(session.getUserProperties()).andReturn(new Properties()).anyTimes();
final AssemblerConfigurationSource cs = mockManager.createMock(AssemblerConfigurationSource.class);
expect(cs.getMavenSession()).andReturn(session).anyTimes();
DefaultAssemblyArchiverTest.setupInterpolators(cs, mainProject);
mockManager.replayAll();
final String result = AssemblyFormatUtils.evaluateFileNameMapping(expression, artifactMock.getArtifact(), mainProject, moduleArtifactMock.getArtifact(), cs, AssemblyFormatUtils.moduleProjectInterpolator(moduleProject), AssemblyFormatUtils.artifactProjectInterpolator(artifactProject));
/*
final String result =
AssemblyFormatUtils.evaluateFileNameMapping( expression,
moduleArtifactInterpolator( moduleArtifactMock.getArtifact() ),
moduleProjectInterpolator( moduleProject ),
artifactInterpolator( artifactMock.getArtifact() ),
artifactProjectInterpolator( artifactProject ),
mainArtifactPropsOnly( mainProject ),
classifierRules( artifactMock.getArtifact() ),
FixedStringSearchInterpolator.create( new
PropertiesBasedValueSource( System.getProperties() )) );
*/
assertEquals(checkValue, result);
mockManager.verifyAll();
// clear out for next call.
mockManager.resetAll();
}
Aggregations