if ( activation == null )
{
return false;
}
ActivationFile file = activation.getFile();
if ( file == null )
{
return false;
}
String path;
boolean missing;
if ( StringUtils.isNotEmpty( file.getExists() ) )
{
path = file.getExists();
missing = false;
}
else if ( StringUtils.isNotEmpty( file.getMissing() ) )
{
path = file.getMissing();
missing = true;
}
else
{
return false;
}
RegexBasedInterpolator interpolator = new RegexBasedInterpolator();
final File basedir = context.getProjectDirectory();
if ( basedir != null )
{
interpolator.addValueSource( new AbstractValueSource( false )
{
public Object getValue( String expression )
{
/*
* NOTE: We intentionally only support ${basedir} and not ${project.basedir} as the latter form
* would suggest that other project.* expressions can be used which is however beyond the design.
*/
if ( "basedir".equals( expression ) )
{
return basedir.getAbsolutePath();
}
return null;
}
} );
}
else if ( path.contains( "${basedir}" ) )
{
return false;
}
interpolator.addValueSource( new MapBasedValueSource( context.getProjectProperties() ) );
interpolator.addValueSource( new MapBasedValueSource( context.getUserProperties() ) );
interpolator.addValueSource( new MapBasedValueSource( context.getSystemProperties() ) );
try
{
path = interpolator.interpolate( path, "" );
}
catch ( Exception e )
{
problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE )
.setMessage( "Failed to interpolate file location " + path + " for profile " + profile.getId() + ": " + e.getMessage() )
.setLocation( file.getLocation( missing ? "missing" : "exists" ) )
.setException( e ) );
return false;
}
path = pathTranslator.alignToBaseDirectory( path, basedir );