ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 12651] New: - jar update with manifest does not merge manifests
Date Sat, 14 Sep 2002 21:45:11 GMT
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: ant-dev@jakarta.apache.org
        ReportedBy: bjenkins@dynamicsoft.com


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:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message