use of org.codehaus.plexus.interpolation.fixed.PropertiesBasedValueSource 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.codehaus.plexus.interpolation.fixed.PropertiesBasedValueSource 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.codehaus.plexus.interpolation.fixed.PropertiesBasedValueSource in project maven-plugins by apache.
the class AssemblyExpressionEvaluatorTest method testShouldResolveContextValueBeforeModelPropertyOrModelGroupIdInAssemblyId.
public void testShouldResolveContextValueBeforeModelPropertyOrModelGroupIdInAssemblyId() throws ExpressionEvaluationException {
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 EasyMockSupport mm = new EasyMockSupport();
MavenSession session = mm.createControl().createMock(MavenSession.class);
final Properties execProps = new Properties();
execProps.setProperty("groupId", "still.another.id");
PropertiesBasedValueSource cliProps = new PropertiesBasedValueSource(execProps);
expect(session.getExecutionProperties()).andReturn(execProps).anyTimes();
expect(session.getUserProperties()).andReturn(new Properties()).anyTimes();
AssemblerConfigurationSource cs = mm.createControl().createMock(AssemblerConfigurationSource.class);
expect(cs.getCommandLinePropsInterpolator()).andReturn(FixedStringSearchInterpolator.create(cliProps)).anyTimes();
expect(cs.getRepositoryInterpolator()).andReturn(FixedStringSearchInterpolator.create()).anyTimes();
expect(cs.getEnvInterpolator()).andReturn(FixedStringSearchInterpolator.create()).anyTimes();
expect(cs.getMavenSession()).andReturn(session).anyTimes();
expect(cs.getProject()).andReturn(new MavenProject(model));
final IMocksControl lrCtl = mm.createControl();
final ArtifactRepository lr = lrCtl.createMock(ArtifactRepository.class);
expect(lr.getBasedir()).andReturn("/path/to/local/repo").anyTimes();
expect(cs.getLocalRepository()).andReturn(lr).anyTimes();
mm.replayAll();
final Object result = new AssemblyExpressionEvaluator(cs).evaluate("assembly.${groupId}");
assertEquals("assembly.still.another.id", result);
mm.verifyAll();
}
use of org.codehaus.plexus.interpolation.fixed.PropertiesBasedValueSource in project maven-plugins by apache.
the class AbstractAssemblyMojo method createRepositoryInterpolator.
private FixedStringSearchInterpolator createRepositoryInterpolator() {
final Properties settingsProperties = new Properties();
final MavenSession session = getMavenSession();
if (getLocalRepository() != null) {
settingsProperties.setProperty("localRepository", getLocalRepository().getBasedir());
settingsProperties.setProperty("settings.localRepository", getLocalRepository().getBasedir());
} else if (session != null && session.getSettings() != null) {
settingsProperties.setProperty("localRepository", session.getSettings().getLocalRepository());
settingsProperties.setProperty("settings.localRepository", getLocalRepository().getBasedir());
}
return FixedStringSearchInterpolator.create(new PropertiesBasedValueSource(settingsProperties));
}
use of org.codehaus.plexus.interpolation.fixed.PropertiesBasedValueSource in project maven-plugins by apache.
the class AssemblyFormatUtils method classifierRules.
@Nonnull
public static FixedStringSearchInterpolator classifierRules(final Artifact artifact) {
final Properties specialRules = new Properties();
final String classifier = ProjectUtils.getClassifier(artifact);
if (classifier != null) {
specialRules.setProperty("dashClassifier?", "-" + classifier);
specialRules.setProperty("dashClassifier", "-" + classifier);
} else {
specialRules.setProperty("dashClassifier?", "");
specialRules.setProperty("dashClassifier", "");
}
return FixedStringSearchInterpolator.create(new PropertiesBasedValueSource(specialRules));
}
Aggregations