ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From co...@apache.org
Subject cvs commit: ant/src/main/org/apache/tools/ant/taskdefs Jar.java ManifestTask.java
Date Sat, 22 Mar 2003 09:39:46 GMT
conor       2003/03/22 01:39:46

  Modified:    src/main/org/apache/tools/ant/loader AntClassLoader2.java
               docs/manual/CoreTasks jar.html manifest.html
               src/main/org/apache/tools/ant/taskdefs Jar.java
                        ManifestTask.java
  Log:
  Add manifest encoding options to control the encoding used to read in
  manifests
  
  PR:	17634
  
  Revision  Changes    Path
  1.6       +2 -1      ant/src/main/org/apache/tools/ant/loader/AntClassLoader2.java
  
  Index: AntClassLoader2.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/loader/AntClassLoader2.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -w -u -r1.5 -r1.6
  --- AntClassLoader2.java	10 Feb 2003 14:13:34 -0000	1.5
  +++ AntClassLoader2.java	22 Mar 2003 09:39:46 -0000	1.6
  @@ -283,7 +283,8 @@
               if (manifestStream == null) {
                   return;
               }                
  -            Reader manifestReader = new InputStreamReader(manifestStream);
  +            Reader manifestReader 
  +                = new InputStreamReader(manifestStream, "UTF-8");
               org.apache.tools.ant.taskdefs.Manifest manifest
                   = new org.apache.tools.ant.taskdefs.Manifest(manifestReader);
               classpath 
  
  
  
  1.25      +5 -0      ant/docs/manual/CoreTasks/jar.html
  
  Index: jar.html
  ===================================================================
  RCS file: /home/cvs/ant/docs/manual/CoreTasks/jar.html,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -w -u -r1.24 -r1.25
  --- jar.html	7 Mar 2003 14:48:52 -0000	1.24
  +++ jar.html	22 Mar 2003 09:39:46 -0000	1.25
  @@ -151,6 +151,11 @@
       <td valign="top">whether to create an <A HREF="http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html#JAR%20Index">index
list</A> to speed up classloading.  This is a JDK 1.3+ specific feature.  Defaults to
false. </td>
       <td valign="top" align="center">No</td>
     </tr>
  +  <tr>
  +    <td valign="top">manifestencoding</td>
  +    <td valign="top">The encoding used to read the JAR manifest, when a manifest
file is specified.</td>
  +    <td valign="top" align="center">No, defaults to the platform encoding.</td>
  +  </tr>
   </table>
   
   <h3>Nested elements</h3>
  
  
  
  1.7       +5 -0      ant/docs/manual/CoreTasks/manifest.html
  
  Index: manifest.html
  ===================================================================
  RCS file: /home/cvs/ant/docs/manual/CoreTasks/manifest.html,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -w -u -r1.6 -r1.7
  --- manifest.html	4 Sep 2002 11:05:16 -0000	1.6
  +++ manifest.html	22 Mar 2003 09:39:46 -0000	1.7
  @@ -39,6 +39,11 @@
       <td valign="top">One of "update" or "replace", default is "replace".</td>
       <td valign="top" align="center">No</td>
     </tr>
  +  <tr>
  +    <td valign="top">encoding</td>
  +    <td valign="top">The encoding used to read the existing manifest when updating.</td>
  +    <td valign="top" align="center">No, defaults to UTF-8 encoding.</td>
  +  </tr>
   </table>
   
   <h3>Nested elements</h3>
  
  
  
  1.72      +45 -7     ant/src/main/org/apache/tools/ant/taskdefs/Jar.java
  
  Index: Jar.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Jar.java,v
  retrieving revision 1.71
  retrieving revision 1.72
  diff -u -w -u -r1.71 -r1.72
  --- Jar.java	12 Mar 2003 11:23:27 -0000	1.71
  +++ Jar.java	22 Mar 2003 09:39:46 -0000	1.72
  @@ -61,6 +61,7 @@
   import java.io.FileInputStream;
   import java.io.IOException;
   import java.io.InputStream;
  +import java.io.UnsupportedEncodingException;
   import java.io.InputStreamReader;
   import java.io.OutputStreamWriter;
   import java.io.PrintWriter;
  @@ -124,6 +125,9 @@
       /** the manifest specified by the 'manifest' attribute **/
       private Manifest manifest;
   
  +    /** The encoding to use when reading in a manifest file */
  +    private String manifestEncoding;
  +    
       /**
        * The file found from the 'manifest' attribute.  This can be
        * either the location of a manifest, or the name of a jar added
  @@ -173,6 +177,14 @@
       }
   
       /**
  +     * Set whether or not to create an index list for classes.
  +     * This may speed up classloading in some cases.
  +     */
  +    public void setManifestEncoding(String manifestEncoding) {
  +        this.manifestEncoding = manifestEncoding;
  +    }
  +
  +    /**
        * Allows the manifest for the archive file to be provided inline
        * in the build file rather than in an external file.
        *
  @@ -212,8 +224,15 @@
           InputStreamReader isr = null;
           try {
               fis = new FileInputStream(manifestFile);
  -            isr = new InputStreamReader(fis, "UTF-8");
  +            if (manifestEncoding == null) {
  +                isr = new InputStreamReader(fis);
  +            } else {
  +                isr = new InputStreamReader(fis, manifestEncoding);
  +            }
               newManifest = getManifest(isr);
  +        } catch (UnsupportedEncodingException e) {
  +            throw new BuildException("Unsupported encoding while reading manifest: "
  +                                     + e.getMessage(), e);
           } catch (IOException e) {
               throw new BuildException("Unable to read manifest file: "
                                        + manifestFile
  @@ -466,11 +485,22 @@
               // If this is the same name specified in 'manifest', this
               // is the manifest to use
               log("Found manifest " + file, Project.MSG_VERBOSE);
  +            try {
               if (is != null) {
  -                manifest = getManifest(new InputStreamReader(is, "UTF-8"));
  +                    InputStreamReader isr;
  +                    if (manifestEncoding == null) {
  +                        isr = new InputStreamReader(is);
  +                    } else {
  +                        isr = new InputStreamReader(is, manifestEncoding);
  +                    }
  +                    manifest = getManifest(isr);
               } else {
                   manifest = getManifest(file);
               }
  +            } catch (UnsupportedEncodingException e) {
  +                throw new BuildException("Unsupported encoding while reading " 
  +                    + "manifest: " + e.getMessage(), e);
  +            }
           } else if (filesetManifestConfig != null &&
                      !filesetManifestConfig.getValue().equals("skip")) {
               // we add this to our group of fileset manifests
  @@ -480,8 +510,13 @@
               try {
                   Manifest newManifest = null;
                   if (is != null) {
  -                    newManifest 
  -                        = getManifest(new InputStreamReader(is, "UTF-8"));
  +                    InputStreamReader isr;
  +                    if (manifestEncoding == null) {
  +                        isr = new InputStreamReader(is);
  +                    } else {
  +                        isr = new InputStreamReader(is, manifestEncoding);
  +                    }
  +                    newManifest = getManifest(isr);
                   } else {
                       newManifest = getManifest(file);
                   }
  @@ -491,6 +526,9 @@
                   } else {
                       filesetManifest.merge(newManifest);
                   }
  +            } catch (UnsupportedEncodingException e) {
  +                throw new BuildException("Unsupported encoding while reading " 
  +                    + "manifest: " + e.getMessage(), e);
               } catch (ManifestException e) {
                   log("Manifest in file " + file + " is invalid: "
                       + e.getMessage(), Project.MSG_ERR);
  
  
  
  1.8       +18 -1     ant/src/main/org/apache/tools/ant/taskdefs/ManifestTask.java
  
  Index: ManifestTask.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/ManifestTask.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -w -u -r1.7 -r1.8
  --- ManifestTask.java	7 Mar 2003 11:23:02 -0000	1.7
  +++ ManifestTask.java	22 Mar 2003 09:39:46 -0000	1.8
  @@ -97,6 +97,11 @@
       private Mode mode;
   
       /**
  +     * The encoding of the manifest file
  +     */
  +    private String encoding;
  +    
  +    /**
        * Helper class for Manifest's mode attribute.
        */
       public static class Mode extends EnumeratedAttribute {
  @@ -149,6 +154,14 @@
       }
   
       /**
  +     * The encoding to use for reading in an existing manifest file
  +     * @param encoding the maniofets file encoding.
  +     */
  +    public void setEncoding(String encoding) {
  +        this.encoding = encoding;
  +    }
  +
  +    /**
        * Update policy: either "update" or "replace"; default is "replace".
        * @param m the mode value - update or replace.
        */
  @@ -175,7 +188,11 @@
               InputStreamReader isr = null;
               try {
                   fis = new FileInputStream(manifestFile);
  +                if (encoding == null) {
                   isr = new InputStreamReader(fis, "UTF-8");
  +                } else {
  +                    isr = new InputStreamReader(fis, encoding);
  +                }
                   current = new Manifest(isr);
               } catch (ManifestException m) {
                   error = new BuildException("Existing manifest " + manifestFile
  
  
  

Mime
View raw message