Skip to content

Commit

Permalink
reset altSettings to null as was modified and cleanup tmp files
Browse files Browse the repository at this point in the history
  • Loading branch information
olamy committed Aug 6, 2011
1 parent f97a65a commit a254f20
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java
Expand Up @@ -561,6 +561,7 @@ protected Result doRun(final BuildListener listener) throws Exception {
PrintStream logger = listener.getLogger();
Result r = null;
File tmpSettingsFile = null;
FilePath remoteSettings = null;
try {

EnvVars envVars = getEnvironment(listener);
Expand Down Expand Up @@ -628,12 +629,10 @@ protected Result doRun(final BuildListener listener) throws Exception {
String settingsContent = config.content;
if (settingsContent != null ) {
tmpSettingsFile = File.createTempFile( "maven-settings", "xml" );
FilePath target = new FilePath(getWorkspace(), tmpSettingsFile.getName());
remoteSettings = new FilePath(getWorkspace(), tmpSettingsFile.getName());
ByteArrayInputStream bs = new ByteArrayInputStream(settingsContent.getBytes());
target.copyFrom(bs);
// FIXME don't store that here as it's saved for next build !!
// FIXME ensure we delete this file in the workspace
project.setAlternateSettings( target.getRemote() );
remoteSettings.copyFrom(bs);
project.setAlternateSettings( remoteSettings.getRemote() );
}
}
}
Expand Down Expand Up @@ -814,7 +813,16 @@ protected Result doRun(final BuildListener listener) throws Exception {
logger.println("project.getRootModule()="+project.getRootModule());
throw e;
} finally {
if (project.getSettingConfigId() != null) {
// restore to null if as was modified
project.setAlternateSettings( null );
project.save();
}
// delete tmp files used for MavenSettingsProvider
FileUtils.deleteQuietly( tmpSettingsFile );
if (remoteSettings != null) {
remoteSettings.delete();
}
}
}

Expand Down

0 comments on commit a254f20

Please sign in to comment.