File hello = createTextFile("hello");
// Create a jar file
final String jarFileName = "um-test.jar";
new File(jarFileName).delete(); // remove pre-existing first!
Main jartool = new Main(out, err, "jar");
boolean status = jartool.run(
new String[] {"cfm", jarFileName,
manifestOrig.getPath(), hello.getPath() });
check(status);
// Create a new manifest, to use in updating the jar file.
File manifestUpdate = File.createTempFile("manifestUpdate", ".txt");
if (!debug) manifestUpdate.deleteOnExit();
pw = new PrintWriter(manifestUpdate);
final String createdBy =
"Created-By: 1.5.0-special (Sun Microsystems Inc.)";
final String specVersion =
"Specification-Version: 1.0.0.0";
pw.println(createdBy); // replaces line in the original
pw.println("");
pw.println(animal);
pw.println(specVersion); // addition to animal/marsupial section
pw.close();
// Update jar file with manifest
jartool = new Main(out, err, "jar");
status = jartool.run(
new String[] { "ufm", jarFileName, manifestUpdate.getPath() });
check(status);
// Extract jar, and verify contents of manifest file
File f = new File(jarFileName);