ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From co...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Jar.java
Date Fri, 21 Jun 2002 06:49:36 GMT
conor       2002/06/20 23:49:36

  Modified:    src/main/org/apache/tools/ant/taskdefs Tag: ANT_15_BRANCH
                        Jar.java
  Log:
  Fix up issues with in line manifests
    Make the default to merge the main section
    Compare manifests with the results of the same code used to write
     the manifest
    Separate manifest generation from writing code
    Remove line separator hack as this is now done in Manifest code
      and it is better to solve there
  
  PR:	9713
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.51.2.7  +32 -33    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.6
  retrieving revision 1.51.2.7
  diff -u -w -u -r1.51.2.6 -r1.51.2.7
  --- Jar.java	19 Jun 2002 02:17:27 -0000	1.51.2.6
  +++ Jar.java	21 Jun 2002 06:49:36 -0000	1.51.2.7
  @@ -112,7 +112,7 @@
        * whether to merge the main section of fileset manifests;
        * value is true if filesetmanifest is 'merge'
        */
  -    private boolean mergeManifestsMain = false;
  +    private boolean mergeManifestsMain = true;
   
       /** the manifest specified by the 'manifest' attribute **/
       private Manifest manifest;
  @@ -267,13 +267,13 @@
           if (filesetManifestConfig == null
               || filesetManifestConfig.getValue().equals("skip")) {
               manifestOnFinalize = false;
  -            createManifest(zOut);
  +            Manifest jarManifest = createManifest();
  +            writeManifest(zOut, jarManifest);
           }
       }
   
  -    private void createManifest(ZipOutputStream zOut)
  +    private Manifest createManifest()
           throws IOException, BuildException {
  -        String ls = System.getProperty("line.separator");
           try {
               Manifest finalManifest = Manifest.getDefaultManifest();
   
  @@ -301,21 +301,27 @@
                   finalManifest.merge(manifest, !mergeManifestsMain);
               }
   
  -            for (Enumeration e = finalManifest.getWarnings();
  +            return finalManifest;
  +
  +        } catch (ManifestException e) {
  +            log("Manifest is invalid: " + e.getMessage(), Project.MSG_ERR);
  +            throw new BuildException("Invalid Manifest", e, getLocation());
  +        }
  +    }
  +
  +    private void writeManifest(ZipOutputStream zOut, Manifest manifest) 
  +         throws IOException {
  +        for (Enumeration e = manifest.getWarnings();
                    e.hasMoreElements();) {
                   log("Manifest warning: " + (String) e.nextElement(),
                       Project.MSG_WARN);
               }
   
  -            // need to set the line.separator as \r\n due to a bug
  -            // with the jar verifier
  -            System.getProperties().put("line.separator", "\r\n");
  -
               zipDir(null, zOut, "META-INF/");
               // time to write the manifest
               ByteArrayOutputStream baos = new ByteArrayOutputStream();
               PrintWriter writer = new PrintWriter(baos);
  -            finalManifest.write(writer);
  +        manifest.write(writer);
               writer.flush();
   
               ByteArrayInputStream bais =
  @@ -323,18 +329,13 @@
               super.zipFile(bais, zOut, "META-INF/MANIFEST.MF",
                             System.currentTimeMillis(), null);
               super.initZipOutputStream(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 (manifestOnFinalize) {
  -            createManifest(zOut);
  +            Manifest jarManifest = createManifest();
  +            writeManifest(zOut, jarManifest);
           }
   
           if (index) {
  @@ -487,10 +488,8 @@
                   Manifest currentManifest =
                       new Manifest(new InputStreamReader(theZipFile
                                                          .getInputStream(entry)));
  -                if (configuredManifest == null) {
  -                    configuredManifest = Manifest.getDefaultManifest();
  -                }
  -                if (!currentManifest.equals(configuredManifest)) {
  +                Manifest newManifest = createManifest();                              
                        
  +                if (!currentManifest.equals(newManifest)) {
                       log("Updating jar since jar manifest has changed",
                           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