ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Zip.java
Date Thu, 12 Jul 2001 07:37:00 GMT
bodewig     01/07/12 00:36:58

  Modified:    .        WHATSNEW
               docs/manual/CoreTasks ear.html jar.html war.html zip.html
               src/main/org/apache/tools/ant/taskdefs Zip.java
  Log:
  New filesonly attribute for <zip> and friends - suppresses directories.
  
  PR: 2053
  Submitted by:	Peter Janes <peterj@liberate.com>
  
  Revision  Changes    Path
  1.126     +3 -0      jakarta-ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/WHATSNEW,v
  retrieving revision 1.125
  retrieving revision 1.126
  diff -u -r1.125 -r1.126
  --- WHATSNEW	2001/07/12 07:09:05	1.125
  +++ WHATSNEW	2001/07/12 07:36:21	1.126
  @@ -102,6 +102,9 @@
   
   * regexp mapper now supports the java.util.regex package of JDK 1.4.
   
  +* New filesonly attribute for <zip> and friends to suppress directory
  +  entries.
  +
   Fixed bugs:
   -----------
   
  
  
  
  1.4       +5 -0      jakarta-ant/docs/manual/CoreTasks/ear.html
  
  Index: ear.html
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/docs/manual/CoreTasks/ear.html,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ear.html	2001/07/05 13:10:24	1.3
  +++ ear.html	2001/07/12 07:36:33	1.4
  @@ -52,6 +52,11 @@
       <td align="center" valign="top">No</td>
     </tr>
     <tr>
  +    <td valign="top">filesonly</td>
  +    <td valign="top">Store only file entries, defaults to false</td>
  +    <td align="center" valign="top">No</td>
  +  </tr>
  +  <tr>
       <td valign="top">includes</td>
       <td valign="top">comma separated list of patterns of files that must be
         included. All files are included when omitted.</td>
  
  
  
  1.5       +5 -0      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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- jar.html	2001/07/05 13:10:24	1.4
  +++ jar.html	2001/07/12 07:36:36	1.5
  @@ -74,6 +74,11 @@
       <td align="center" valign="top">No</td>
     </tr>
     <tr>
  +    <td valign="top">filesonly</td>
  +    <td valign="top">Store only file entries, defaults to false</td>
  +    <td align="center" valign="top">No</td>
  +  </tr>
  +  <tr>
       <td valign="top">includes</td>
       <td valign="top">comma separated list of patterns of files that must be
         included. All files are included when omitted.</td>
  
  
  
  1.5       +5 -0      jakarta-ant/docs/manual/CoreTasks/war.html
  
  Index: war.html
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/docs/manual/CoreTasks/war.html,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- war.html	2001/07/05 13:10:24	1.4
  +++ war.html	2001/07/12 07:36:37	1.5
  @@ -54,6 +54,11 @@
       <td align="center" valign="top">No</td>
     </tr>
     <tr>
  +    <td valign="top">filesonly</td>
  +    <td valign="top">Store only file entries, defaults to false</td>
  +    <td align="center" valign="top">No</td>
  +  </tr>
  +  <tr>
       <td valign="top">includes</td>
       <td valign="top">comma separated list of patterns of files that must be
         included. All files are included when omitted.</td>
  
  
  
  1.4       +5 -0      jakarta-ant/docs/manual/CoreTasks/zip.html
  
  Index: zip.html
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/docs/manual/CoreTasks/zip.html,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- zip.html	2001/07/05 13:10:24	1.3
  +++ zip.html	2001/07/12 07:36:39	1.4
  @@ -75,6 +75,11 @@
       <td align="center" valign="top">No</td>
     </tr>
     <tr>
  +    <td valign="top">filesonly</td>
  +    <td valign="top">Store only file entries, defaults to false</td>
  +    <td align="center" valign="top">No</td>
  +  </tr>
  +  <tr>
       <td valign="top">includes</td>
       <td valign="top">comma separated list of patterns of files that must be
         included. All files are included when omitted.</td>
  
  
  
  1.40      +29 -20    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Zip.java
  
  Index: Zip.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Zip.java,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- Zip.java	2001/07/05 13:10:26	1.39
  +++ Zip.java	2001/07/12 07:36:50	1.40
  @@ -78,6 +78,7 @@
       private File zipFile;
       private File baseDir;
       private boolean doCompress = true;
  +    private boolean doFilesonly = false;
       protected String archiveType = "zip";
       // For directories:
       private static long emptyCrc = new CRC32 ().getValue ();
  @@ -115,6 +116,13 @@
       }
   
       /**
  +     * Emulate Sun's jar utility by not adding parent dirs
  +     */
  +    public void setFilesonly(boolean f) {
  +        doFilesonly = f;
  +    }
  +
  +    /**
        * Adds a set of files (nested fileset attribute).
        */
       public void addFileset(FileSet set) {
  @@ -529,27 +537,28 @@
       protected void addParentDirs(File baseDir, String entry,
                                    ZipOutputStream zOut, String prefix)
           throws IOException {
  -
  -        Stack directories = new Stack();
  -        int slashPos = entry.length();
  -
  -        while ((slashPos = entry.lastIndexOf((int)'/', slashPos-1)) != -1) {
  -            String dir = entry.substring(0, slashPos+1);
  -            if (addedDirs.get(prefix+dir) != null) {
  -                break;
  -            }
  -            directories.push(dir);
  -        }
  -
  -        while (!directories.isEmpty()) {
  -            String dir = (String) directories.pop();
  -            File f = null;
  -            if (baseDir != null) {
  -                f = new File(baseDir, dir);
  -            } else {
  -                f = new File(dir);
  +        if( !doFilesonly ) {
  +            Stack directories = new Stack();
  +            int slashPos = entry.length();
  +            
  +            while ((slashPos = entry.lastIndexOf((int)'/', slashPos-1)) != -1) {
  +                String dir = entry.substring(0, slashPos+1);
  +                if (addedDirs.get(prefix+dir) != null) {
  +                    break;
  +                }
  +                directories.push(dir);
  +            }
  +            
  +            while (!directories.isEmpty()) {
  +                String dir = (String) directories.pop();
  +                File f = null;
  +                if (baseDir != null) {
  +                    f = new File(baseDir, dir);
  +                } else {
  +                    f = new File(dir);
  +                }
  +                zipDir(f, zOut, prefix+dir);
               }
  -            zipDir(f, zOut, prefix+dir);
           }
       }
   
  
  
  

Mime
View raw message