public void repackage(File destination, Libraries libraries,
			LaunchScript launchScript) throws IOException {
		if (destination == null || destination.isDirectory()) {
			throw new IllegalArgumentException("Invalid destination");
		}
		if (libraries == null) {
			throw new IllegalArgumentException("Libraries must not be null");
		}
		if (this.layout == null) {
			this.layout = getLayoutFactory().getLayout(this.source);
		}
		destination = destination.getAbsoluteFile();
		File workingSource = this.source;
		if (alreadyRepackaged() && this.source.equals(destination)) {
			return;
		}
		if (this.source.equals(destination)) {
			workingSource = getBackupFile();
			workingSource.delete();
			renameFile(this.source, workingSource);
		}
		destination.delete();
		try {
			try (JarFile jarFileSource = new JarFile(workingSource)) {
				repackage(jarFileSource, destination, libraries, launchScript);
			}
		}
		finally {
			if (!this.backupSource && !this.source.equals(workingSource)) {
				deleteFile(workingSource);
			}
		}
	}
public void repackage ( File destination , Libraries libraries , LaunchScript launchScript ) throws IOException { if ( destination == null || destination . isDirectory ( ) ) { throw new IllegalArgumentException ( "Invalid destination" ) ; } if ( libraries == null ) { throw new IllegalArgumentException ( "Libraries must not be null" ) ; } if ( this . layout == null ) { this . layout = getLayoutFactory ( ) . getLayout ( this . source ) ; } destination = destination . getAbsoluteFile ( ) ; File workingSource = this . source ; if ( alreadyRepackaged ( ) && this . source . equals ( destination ) ) { return ; } if ( this . source . equals ( destination ) ) { workingSource = getBackupFile ( ) ; workingSource . delete ( ) ; renameFile ( this . source , workingSource ) ; } destination . delete ( ) ; try { try ( JarFile jarFileSource = new JarFile ( workingSource ) ) { repackage ( jarFileSource , destination , libraries , launchScript ) ; } } finally { if ( ! this . backupSource && ! this . source . equals ( workingSource ) ) { deleteFile ( workingSource ) ; } } }
Repackage to the given destination so that it can be launched using '
{@literal java -jar}'.
@param destination the destination file (may be the same as the source)
@param libraries the libraries required to run the archive
@param launchScript an optional launch script prepended to the front of the jar
@throws IOException if the file cannot be repackaged
@since 1.3.0