* @see org.apache.maven.settings.DefaultMavenSettingsBuilder#readSettings
*/
private Settings readSettings( File settingsFile )
throws IOException, XmlPullParserException
{
Settings settings = null;
Reader reader = null;
try
{
reader = ReaderFactory.newXmlReader( settingsFile );
StringWriter sWriter = new StringWriter();
IOUtil.copy( reader, sWriter );
String rawInput = sWriter.toString();
try
{
RegexBasedInterpolator interpolator = new RegexBasedInterpolator();
interpolator.addValueSource( new EnvarBasedValueSource() );
rawInput = interpolator.interpolate( rawInput, "settings" );
}
catch ( Exception e )
{
log( "Failed to initialize environment variable resolver. Skipping environment substitution in settings." );
}
StringReader sReader = new StringReader( rawInput );
SettingsXpp3Reader modelReader = new SettingsXpp3Reader();
settings = modelReader.read( sReader );
RuntimeInfo rtInfo = new RuntimeInfo( settings );
rtInfo.setFile( settingsFile );
settings.setRuntimeInfo( rtInfo );
}
finally
{
IOUtil.close( reader );
}