ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From umag...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Jar.java
Date Wed, 08 May 2002 22:27:46 GMT
umagesh     02/05/08 15:27:46

  Modified:    src/main/org/apache/tools/ant/taskdefs Tag: ANT_15_BRANCH
                        Jar.java
  Log:
  Move building of final manifest from initZipOutputStream to finalizeZipOutputStream so that
merged entries of the manifests appear properly as documented.
  
  Reported by: Juergen Damke <DAMKE@de.ibm.com>
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.51.2.1  +28 -27    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
  retrieving revision 1.51.2.1
  diff -u -r1.51 -r1.51.2.1
  --- Jar.java	15 Apr 2002 15:33:08 -0000	1.51
  +++ Jar.java	8 May 2002 22:27:46 -0000	1.51.2.1
  @@ -78,7 +78,7 @@
    * Creates a JAR archive.
    *
    * @author James Davidson <a href="mailto:duncan@x180.com">duncan@x180.com</a>
  - * @author Brian Deitte 
  + * @author Brian Deitte
    *         <a href="mailto:bdeitte@macromedia.com">bdeitte@macromedia.com</a>
    *
    * @since Ant 1.1
  @@ -151,7 +151,7 @@
           index = flag;
       }
   
  -    public void addConfiguredManifest(Manifest newManifest) 
  +    public void addConfiguredManifest(Manifest newManifest)
           throws ManifestException {
           if (configuredManifest == null) {
               configuredManifest = newManifest;
  @@ -178,8 +178,8 @@
               r = new FileReader(manifestFile);
               newManifest = getManifest(r);
           } catch (IOException e) {
  -            throw new BuildException("Unable to read manifest file: " 
  -                                     + manifestFile 
  +            throw new BuildException("Unable to read manifest file: "
  +                                     + manifestFile
                                        + " (" + e.getMessage() + ")", e);
           } finally {
               if (r != null) {
  @@ -200,7 +200,7 @@
               newManifest = new Manifest(r);
           } catch (ManifestException e) {
               log("Manifest is invalid: " + e.getMessage(), Project.MSG_ERR);
  -            throw new BuildException("Invalid Manifest: " + manifestFile, 
  +            throw new BuildException("Invalid Manifest: " + manifestFile,
                                        e, getLocation());
           } catch (IOException e) {
               throw new BuildException("Unable to read manifest file"
  @@ -223,6 +223,11 @@
   
       protected void initZipOutputStream(ZipOutputStream zOut)
           throws IOException, BuildException {
  +        super.initZipOutputStream(zOut);
  +    }
  +
  +    protected void finalizeZipOutputStream(ZipOutputStream zOut)
  +            throws IOException, BuildException {
           String ls = System.getProperty("line.separator");
   
           try {
  @@ -239,7 +244,7 @@
                   } else if (configuredManifest != null) {
                       // configuredManifest is the final merge
                       finalManifest.merge(filesetManifest);
  -                    finalManifest.merge(configuredManifest, 
  +                    finalManifest.merge(configuredManifest,
                                           !mergeManifestsMain);
                   } else if (filesetManifest != null) {
                       // filesetManifest is the final (and only) merge
  @@ -252,9 +257,9 @@
                   finalManifest.merge(manifest, !mergeManifestsMain);
               }
   
  -            for (Enumeration e = finalManifest.getWarnings(); 
  +            for (Enumeration e = finalManifest.getWarnings();
                    e.hasMoreElements();) {
  -                log("Manifest warning: " + (String) e.nextElement(), 
  +                log("Manifest warning: " + (String) e.nextElement(),
                       Project.MSG_WARN);
               }
   
  @@ -269,21 +274,17 @@
               finalManifest.write(writer);
               writer.flush();
   
  -            ByteArrayInputStream bais = 
  +            ByteArrayInputStream bais =
                   new ByteArrayInputStream(baos.toByteArray());
  -            super.zipFile(bais, zOut, "META-INF/MANIFEST.MF", 
  +            super.zipFile(bais, zOut, "META-INF/MANIFEST.MF",
                             System.currentTimeMillis(), null);
  -            super.initZipOutputStream(zOut);
  +            super.finalizeZipOutputStream(zOut);
           } catch (ManifestException e) {
               log("Manifest is invalid: " + e.getMessage(), Project.MSG_ERR);
               throw new BuildException("Invalid Manifest", e, getLocation());
           } finally {
               System.getProperties().put("line.separator", ls);
           }
  -    }
  -
  -    protected void finalizeZipOutputStream(ZipOutputStream zOut)
  -            throws IOException, BuildException {
           if (index) {
               createIndexList(zOut);
           }
  @@ -302,7 +303,7 @@
       private void createIndexList(ZipOutputStream zOut) throws IOException {
           ByteArrayOutputStream baos = new ByteArrayOutputStream();
           // encoding must be UTF8 as specified in the specs.
  -        PrintWriter writer = new PrintWriter(new OutputStreamWriter(baos, 
  +        PrintWriter writer = new PrintWriter(new OutputStreamWriter(baos,
                                                                       "UTF8"));
   
           // version-info blankline
  @@ -338,7 +339,7 @@
           }
   
           writer.flush();
  -        ByteArrayInputStream bais = 
  +        ByteArrayInputStream bais =
               new ByteArrayInputStream(baos.toByteArray());
           super.zipFile(bais, zOut, INDEX_NAME, System.currentTimeMillis(), null);
       }
  @@ -380,7 +381,7 @@
               }
           } else if (mergeManifests) {
               // we add this to our group of fileset manifests
  -            log("Found manifest to merge in file " + file, 
  +            log("Found manifest to merge in file " + file,
                   Project.MSG_VERBOSE);
   
               try {
  @@ -391,14 +392,14 @@
                       filesetManifest.merge(newManifest);
                   }
               } catch (ManifestException e) {
  -                log("Manifest in file " + file + " is invalid: " 
  +                log("Manifest in file " + file + " is invalid: "
                       + e.getMessage(), Project.MSG_ERR);
                   throw new BuildException("Invalid Manifest", e, getLocation());
               }
           } else {
               // assuming 'skip' otherwise
  -            log("File " + file 
  -                + " includes a META-INF/MANIFEST.MF which will be ignored. " 
  +            log("File " + file
  +                + " includes a META-INF/MANIFEST.MF which will be ignored. "
                   + "To include this file, set filesetManifest to a value other "
                   + "than 'skip'.", Project.MSG_WARN);
           }
  @@ -412,34 +413,34 @@
        *         already); false if archive creation should proceed
        * @exception BuildException if it likes
        */
  -    protected boolean isUpToDate(FileScanner[] scanners, File zipFile) 
  +    protected boolean isUpToDate(FileScanner[] scanners, File zipFile)
           throws BuildException {
           // need to handle manifest as a special check
           if (configuredManifest != null || manifestFile == null) {
               java.util.zip.ZipFile theZipFile = null;
               try {
                   theZipFile = new java.util.zip.ZipFile(zipFile);
  -                java.util.zip.ZipEntry entry = 
  +                java.util.zip.ZipEntry entry =
                       theZipFile.getEntry("META-INF/MANIFEST.MF");
                   if (entry == null) {
  -                    log("Updating jar since the current jar has no manifest", 
  +                    log("Updating jar since the current jar has no manifest",
                           Project.MSG_VERBOSE);
                       return false;
                   }
  -                Manifest currentManifest = 
  +                Manifest currentManifest =
                       new Manifest(new InputStreamReader(theZipFile
                                                          .getInputStream(entry)));
                   if (configuredManifest == null) {
                       configuredManifest = Manifest.getDefaultManifest();
                   }
                   if (!currentManifest.equals(configuredManifest)) {
  -                    log("Updating jar since jar manifest has changed", 
  +                    log("Updating jar since jar manifest has changed",
                           Project.MSG_VERBOSE);
                       return false;
                   }
               } catch (Exception e) {
                   // any problems and we will rebuild
  -                log("Updating jar since cannot read current jar manifest: " 
  +                log("Updating jar since cannot read current jar manifest: "
                       + e.getClass().getName() + " - " + e.getMessage(),
                       Project.MSG_VERBOSE);
                   return false;
  
  
  

--
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