umagesh     02/05/21 15:46:32

  Modified:    docs/manual/CoreTasks Tag: ANT_15_BRANCH jar.html
               src/main/org/apache/tools/ant/taskdefs Tag: ANT_15_BRANCH
                        Jar.java
  Log:
  Merge manifests option was not working earlier.  This patch creates a merged 
manifest properly though the resultant jar will be unreadable using 
JarInputStream.  However, if user does not choose to merge manifests, the 
created jar will be readable by JarInputStream.  This is a "For Now" fix.
  
  Submitted by: Brian Deitte <[EMAIL PROTECTED]>
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.16.2.2  +16 -9     jakarta-ant/docs/manual/CoreTasks/jar.html
  
  Index: jar.html
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/docs/manual/CoreTasks/jar.html,v
  retrieving revision 1.16.2.1
  retrieving revision 1.16.2.2
  diff -u -r1.16.2.1 -r1.16.2.2
  --- jar.html  3 May 2002 09:40:28 -0000       1.16.2.1
  +++ jar.html  21 May 2002 22:46:32 -0000      1.16.2.2
  @@ -39,15 +39,15 @@
   updated with the files specified. When set to <code>no</code> (the
   default) the JAR file is overwritten. An example use of this is
   provided in the <a href="zip.html">Zip task documentation</a>.</p>
  -<p>(The Jar task is a shortcut for specifying the manifest file of a JAR 
file. 
  +<p>(The Jar task is a shortcut for specifying the manifest file of a JAR 
file.
   The same thing can be accomplished by using the <i>fullpath</i>
   attribute of a zipfileset in a Zip task. The one difference is that if the
  -<i>manifest</i> attribute is not specified, the Jar task will 
  +<i>manifest</i> attribute is not specified, the Jar task will
   include an empty one for you.)</p>
   
  -<p>Manifests are processed by the Jar task according to the 
  +<p>Manifests are processed by the Jar task according to the
   <a href="http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html";>Jar file 
specification.</a>
  -Note in particular that this may result in manifest lines greater than 72 
bytes 
  +Note in particular that this may result in manifest lines greater than 72 
bytes
   being wrapped and continued on the next line.
   </p>
   
  @@ -123,7 +123,14 @@
     </tr>
     <tr>
       <td valign="top">filesetmanifest</td>
  -    <td valign="top">behavior when a Manifest is found in a zipfileset or 
zipgroupfileset file is found.  Valid values are &quot;skip&quot;, 
&quot;merge&quot;, and &quot;mergewithoutmain&quot;.  &quot;merge&quot; will 
merge all of manifests together, and merge this into any other specified 
manifests.  &quot;mergewithoutmain&quot; merges everything but the Main section 
of the manifests.  Default value is &quot;skip&quot;.
  +    <td valign="top">behavior when a Manifest is found in a zipfileset or
  +    zipgroupfileset file is found.  Valid values are &quot;skip&quot;,
  +    &quot;merge&quot;, and &quot;mergewithoutmain&quot;.  &quot;merge&quot;
  +    will merge all of manifests together, and merge this into any other
  +    specified manifests.  &quot;mergewithoutmain&quot; merges everything
  +    but the Main section of the manifests.  Default value is 
&quot;skip&quot;.
  +    <b>Note:</b> if this attribute's value is not &quot;skip&quot;, the
  +    created jar will not be readable by using java.util.jar.JarInputStream
       </td>
       <td valign="top" align="center">No</td>
     </tr>
  @@ -161,17 +168,17 @@
   <h4>Manifest</h4>
   <p>The manifest nested element allows the manifest for the Jar file to
   be provided inline in the build file rather than in an external
  -file. This element is identical to the 
  +file. This element is identical to the
   <a href="manifest.html">manifest</a> task, but its file and mode
   attributes will be ignored.</p>
   <p>
   If both an inline manifest and an external file are both specified, the
  -manifests are merged. 
  +manifests are merged.
   </p>
   
   <p>When using inline manifests, the Jar task will check whether the build
   file is more recent that the Jar file when deciding whether to rebuild the
  -Jar. This will not take into account property file changes which may affect 
  +Jar. This will not take into account property file changes which may affect
   the resulting Jar.
   </p>
   
  @@ -221,7 +228,7 @@
     &lt;/jar&gt;</pre>
   <p>
   This is an example of an inline manifest specification. Note that the 
Built-By
  -attribute will take the value of the Ant property ${user.name}. The manifest 
  +attribute will take the value of the Ant property ${user.name}. The manifest
   produced by the above would look like this:
   </p>
   <pre><code>Manifest-Version: 1.0
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.51.2.3  +17 -1     
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Jar.java
  
  Index: Jar.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Jar.java,v
  retrieving revision 1.51.2.2
  retrieving revision 1.51.2.3
  diff -u -r1.51.2.2 -r1.51.2.3
  --- Jar.java  15 May 2002 20:06:30 -0000      1.51.2.2
  +++ Jar.java  21 May 2002 22:46:32 -0000      1.51.2.3
  @@ -104,6 +104,11 @@
       private boolean mergeManifests = false;
   
       /**
  +     *  Whether to create manifest file on finalizeOutputStream?
  +     */
  +    private boolean manifestOnFinalize = true;
  +
  +    /**
        * whether to merge the main section of fileset manifests;
        * value is true if filesetmanifest is 'merge'
        */
  @@ -223,8 +228,15 @@
   
       protected void initZipOutputStream(ZipOutputStream zOut)
           throws IOException, BuildException {
  -        String ls = System.getProperty("line.separator");
  +        if (! (mergeManifests || mergeManifestsMain)) {
  +            manifestOnFinalize = false;
  +            createManifest(zOut);
  +        }
  +    }
   
  +    private void createManifest(ZipOutputStream zOut)
  +        throws IOException, BuildException {
  +        String ls = System.getProperty("line.separator");
           try {
               Manifest finalManifest = Manifest.getDefaultManifest();
   
  @@ -284,6 +296,10 @@
   
       protected void finalizeZipOutputStream(ZipOutputStream zOut)
               throws IOException, BuildException {
  +        if (manifestOnFinalize) {
  +            createManifest(zOut);
  +        }
  +
           if (index) {
               createIndexList(zOut);
           }
  
  
  

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

Reply via email to