final AssemblerConfigurationSource configSource )
{
final StringSearchInterpolator interpolator = new StringSearchInterpolator();
interpolator.setCacheAnswers( true );
final MavenSession session = configSource.getMavenSession();
if ( session != null )
{
Properties userProperties = null;
try
{
userProperties = session.getExecutionProperties();
}
catch ( final NoSuchMethodError nsmer )
{
// OK, so user is using Maven <= 2.0.8. No big deal.
}
if ( userProperties != null )
{
// 4
interpolator.addValueSource( new PropertiesBasedValueSource( userProperties ) );
}
}
interpolator.addValueSource( new PrefixedPropertiesValueSource(
InterpolationConstants.PROJECT_PROPERTIES_PREFIXES,
project.getProperties(), true ) );
interpolator.addValueSource( new PrefixedObjectValueSource( InterpolationConstants.PROJECT_PREFIXES, project,
true ) );
final Properties settingsProperties = new Properties();
if ( configSource.getLocalRepository() != null )
{
settingsProperties.setProperty( "localRepository", configSource.getLocalRepository().getBasedir() );
settingsProperties.setProperty( "settings.localRepository", configSource.getLocalRepository().getBasedir() );
}
else if ( session != null && session.getSettings() != null )
{
settingsProperties.setProperty( "localRepository", session.getSettings().getLocalRepository() );
settingsProperties.setProperty( "settings.localRepository", configSource.getLocalRepository().getBasedir() );
}
interpolator.addValueSource( new PropertiesBasedValueSource( settingsProperties ) );
Properties commandLineProperties = System.getProperties();
if ( session != null )
{
commandLineProperties = new Properties();
if ( session.getExecutionProperties() != null )
{
commandLineProperties.putAll( session.getExecutionProperties() );
}
if ( session.getUserProperties() != null )
{
commandLineProperties.putAll( session.getUserProperties() );
}
}
// 7
interpolator.addValueSource( new PropertiesBasedValueSource( commandLineProperties ) );