DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12651>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12651

jar update with manifest does not merge manifests

           Summary: jar update with manifest does not merge manifests
           Product: Ant
           Version: 1.5
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Core tasks
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


Steps to dupe:

1. Create a jar with a few entries
2. Sign the jar using the signjar task
3. Update the jar with a specified manifest containing at least one section 
with entries
4. The specified manifest replaces the original manifest containing the SHA1-
Digest for the signed files

To fix the problem, I made the following modification to the Jar task:

1.  Add a Manifest reference to the Jar task

    private Manifest originalManifest;

2.  Override the setDestFile(File) method to grab the original manifest

    public void setDestFile(File destFile) {
      super.setDestFile(destFile);
      try {
        JarFile jf = new JarFile(destFile);

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        jf.getManifest().write(out);
        jf.close();
        ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
        originalManifest = new Manifest(new InputStreamReader(in));
      }
      catch (Throwable t) {
        originalManifest = null;
      }
    }

3.  Modify the createManifest() method to use the originalManifest

    private Manifest createManifest()
        throws IOException, BuildException {
        try {
            Manifest finalManifest = null;  // changed 
            if (originalManifest != null && this.isInUpdateMode()) // changed 
               finalManifest = originalManifest; // changed
            else finalManifest = Manifest.getDefaultManifest();  // changed
            if (manifest == null) {

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to