public void rewriteHudsonWar ( File by ) throws IOException { File dest = getHudsonWar ( ) ; // this should be impossible given the canRewriteHudsonWar method, // but let's be defensive if ( dest == null ) throw new IOException ( "jenkins.war location is not known." ) ; // backing up the old jenkins.war before it gets lost due to upgrading // (newly downloaded jenkins.war and 'backup' (jenkins.war.tmp) are the same files // unless we are trying to rewrite jenkins.war by a backup itself File bak = new File ( dest . getPath ( ) + ".bak" ) ; if ( ! by . equals ( bak ) ) FileUtils . copyFile ( dest , bak ) ; FileUtils . copyFile ( by , dest ) ; // we don't want to keep backup if we are downgrading if ( by . equals ( bak ) && bak . exists ( ) ) bak . delete ( ) ; }
Replaces jenkins . war by the given file .