src/com/esotericsoftware/scar/Jar.java
static public void mergeJars (String firstJar, String secondJar, String outJar) throws IOException {
		if (DEBUG) debug("scar", "Merging JARs: " + firstJar + " + " + secondJar + " -> " + outJar);

		JarFile firstJarFile = new JarFile(firstJar);
		JarFile secondJarFile = new JarFile(secondJar);

		HashSet<String> names = new HashSet();
		for (Enumeration<JarEntry> entries = firstJarFile.entries(); entries.hasMoreElements();)
			names.add(entries.nextElement().getName().replace('\\', '/'));
		for (Enumeration<JarEntry> entries = secondJarFile.entries(); entries.hasMoreElements();)
			names.add(entries.nextElement().getName().replace('\\', '/'));

		mkdir(parent(outJar));
		JarOutputStream outJarStream = new JarOutputStream(new FileOutputStream(outJar));
		outJarStream.setLevel(Deflater.BEST_COMPRESSION);
		for (String name : names) {
			InputStream input;
			ZipEntry entry = firstJarFile.getEntry(name);
			if (entry != null)
				input = firstJarFile.getInputStream(entry);
			else {
				entry = firstJarFile.getEntry(name.replace('/', '\\'));
				if (entry != null)
					input = firstJarFile.getInputStream(entry);
				else {
					entry = secondJarFile.getEntry(name);
					input = secondJarFile.getInputStream(entry != null ? entry : secondJarFile.getEntry(name.replace('/', '\\')));
				}
			}
			outJarStream.putNextEntry(new JarEntry(name));
			copyStream(input, outJarStream);
			outJarStream.closeEntry();
		}
		firstJarFile.close();
		secondJarFile.close();
		outJarStream.close();
	}
/** Combines the JARs into one. If both JARs have the same entry, the entry from the first JAR is used. */
Combines the JARs into one. If both JARs have the same entry, the entry from the first JAR is used.
Combines the JARs into one . If both JARs have the same entry the entry from the first JAR is used .
static public void mergeJars (String firstJar, String secondJar, String outJar) throws IOException {
		if (DEBUG) debug("scar", "Merging JARs: " + firstJar + " + " + secondJar + " -> " + outJar);
		JarFile firstJarFile = new JarFile(firstJar);
		JarFile secondJarFile = new JarFile(secondJar);
		HashSet<String> names = new HashSet();
		for (Enumeration<JarEntry> entries = firstJarFile.entries(); entries.hasMoreElements();)
			names.add(entries.nextElement().getName().replace('\\', '/'));
		for (Enumeration<JarEntry> entries = secondJarFile.entries(); entries.hasMoreElements();)
			names.add(entries.nextElement().getName().replace('\\', '/'));
		mkdir(parent(outJar));
		JarOutputStream outJarStream = new JarOutputStream(new FileOutputStream(outJar));
		outJarStream.setLevel(Deflater.BEST_COMPRESSION);
		for (String name : names) {
			InputStream input;
			ZipEntry entry = firstJarFile.getEntry(name);
			if (entry != null)
				input = firstJarFile.getInputStream(entry);
			else {
				entry = firstJarFile.getEntry(name.replace('/', '\\'));
				if (entry != null)
					input = firstJarFile.getInputStream(entry);
				else {
					entry = secondJarFile.getEntry(name);
					input = secondJarFile.getInputStream(entry != null ? entry : secondJarFile.getEntry(name.replace('/', '\\')));
				}
			}
			outJarStream.putNextEntry(new JarEntry(name));
			copyStream(input, outJarStream);
			outJarStream.closeEntry();
		}
		firstJarFile.close();
		secondJarFile.close();
		outJarStream.close();
	}
static public void mergeJars ( String firstJar , String secondJar , String outJar ) throws IOException { if ( DEBUG ) debug ( "scar" , "Merging JARs: " + firstJar + " + " + secondJar + " -> " + outJar ) ; JarFile firstJarFile = new JarFile ( firstJar ) ; JarFile secondJarFile = new JarFile ( secondJar ) ; HashSet < String > names = new HashSet ( ) ; for ( Enumeration < JarEntry > entries = firstJarFile . entries ( ) ; entries . hasMoreElements ( ) ; ) names . add ( entries . nextElement ( ) . getName ( ) . replace ( '\\' , '/' ) ) ; for ( Enumeration < JarEntry > entries = secondJarFile . entries ( ) ; entries . hasMoreElements ( ) ; ) names . add ( entries . nextElement ( ) . getName ( ) . replace ( '\\' , '/' ) ) ; mkdir ( parent ( outJar ) ) ; JarOutputStream outJarStream = new JarOutputStream ( new FileOutputStream ( outJar ) ) ; outJarStream . setLevel ( Deflater . BEST_COMPRESSION ) ; for ( String name : names ) { InputStream input ; ZipEntry entry = firstJarFile . getEntry ( name ) ; if ( entry != null ) input = firstJarFile . getInputStream ( entry ) ; else { entry = firstJarFile . getEntry ( name . replace ( '/' , '\\' ) ) ; if ( entry != null ) input = firstJarFile . getInputStream ( entry ) ; else { entry = secondJarFile . getEntry ( name ) ; input = secondJarFile . getInputStream ( entry != null ? entry : secondJarFile . getEntry ( name . replace ( '/' , '\\' ) ) ) ; } } outJarStream . putNextEntry ( new JarEntry ( name ) ) ; copyStream ( input , outJarStream ) ; outJarStream . closeEntry ( ) ; } firstJarFile . close ( ) ; secondJarFile . close ( ) ; outJarStream . close ( ) ; }
Combines the JARs into one.
Combines the JARs into one .