//-----------------------------------------------
// merge settings file
//-----------------------------------------------
SettingsXpp3Writer settingsWriter = new SettingsXpp3Writer();
File mergedSettingsFile;
Settings mergedSettings = this.settings;
if ( mergeUserSettings )
{
if ( interpolatedSettingsFile != null )
{
// Have to merge the specified settings file (dominant) and the one of the invoking Maven process
Reader reader = null;
try
{
reader = new XmlStreamReader( interpolatedSettingsFile );
SettingsXpp3Reader settingsReader = new SettingsXpp3Reader();
Settings dominantSettings = settingsReader.read( reader );
// MINVOKER-137: NPE on dominantSettings.getRuntimeInfo()
// DefaultMavenSettingsBuilder does the same trick
if ( dominantSettings.getRuntimeInfo() == null )
{
RuntimeInfo rtInfo = new RuntimeInfo( dominantSettings );
rtInfo.setFile( interpolatedSettingsFile );
dominantSettings.setRuntimeInfo( rtInfo );
}
Settings recessiveSettings = cloneSettings();
SettingsUtils.merge( dominantSettings, recessiveSettings, TrackableBase.USER_LEVEL );
mergedSettings = dominantSettings;
getLog().debug( "Merged specified settings file with settings of invoking process" );
}
catch ( XmlPullParserException e )
{
throw new MojoExecutionException( "Could not read specified settings file", e );
}
catch ( IOException e )
{
throw new MojoExecutionException( "Could not read specified settings file", e );
}
finally
{
IOUtil.close( reader );
}
}
}
if ( this.settingsFile != null && !mergeUserSettings )
{
mergedSettingsFile = interpolatedSettingsFile;
}
else
{
try
{
mergedSettingsFile = File.createTempFile( "invoker-settings", ".xml" );
FileWriter fileWriter = null;
try
{
fileWriter = new FileWriter( mergedSettingsFile );
settingsWriter.write( fileWriter, mergedSettings );
}
finally
{
IOUtil.close( fileWriter );
}