ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@locus.apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/types FileSet.java
Date Tue, 31 Oct 2000 13:53:08 GMT
bodewig     00/10/31 05:53:08

  Modified:    .        WHATSNEW
               docs     index.html
               src/main/org/apache/tools/ant/taskdefs War.java
               src/main/org/apache/tools/ant/types FileSet.java
  Log:
  Added a nested prefixedfileset element to <war>
  
  Revision  Changes    Path
  1.41      +2 -0      jakarta-ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/WHATSNEW,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- WHATSNEW	2000/10/31 12:13:11	1.40
  +++ WHATSNEW	2000/10/31 13:52:56	1.41
  @@ -8,6 +8,8 @@
   
   * Added output attribute to <java>.
   
  +* Added nested prefixedfileset element to <war>
  +
   Fixed bugs:
   -----------
   
  
  
  
  1.141     +67 -4     jakarta-ant/docs/index.html
  
  Index: index.html
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/docs/index.html,v
  retrieving revision 1.140
  retrieving revision 1.141
  diff -u -r1.140 -r1.141
  --- index.html	2000/10/31 12:13:13	1.140
  +++ index.html	2000/10/31 13:53:04	1.141
  @@ -26,7 +26,7 @@
     <li>Dave Walend (<a href="mailto:dwalend@cs.tufts.edu">dwalend@cs.tufts.edu</a>)</li>
   </ul>
   
  -<p>Version 1.3 - 2000/10/27</p>
  +<p>Version 1.3 - 2000/10/31</p>
   
   <hr>
   <h2>Table of Contents</h2>
  @@ -4220,9 +4220,12 @@
   <h2><a name="war">War</a></h2>
   <h3>Description</h3>
   <p>An extension of the <a href="#jar">Jar</a> task with special
  -treatment for files that should end up in the <code>WEB-INF/lib</code>,
  -<code>WEB-INF/classes</code> or <code>WEB-INF</code> directories
of the Web
  -Application Archive.</p>
  +treatment for files that should end up in the
  +<code>WEB-INF/lib</code>, <code>WEB-INF/classes</code> or
  +<code>WEB-INF</code> directories of the Web Application Archive. It
  +also gives you more control over where your files end up in the
  +archive by means of its nested <code>prefixedfileset</code>
  +element.</p>
   <h3>Parameters</h3>
   <table border="1" cellpadding="2" cellspacing="0">
     <tr>
  @@ -4306,6 +4309,60 @@
   end up in the <code>WEB-INF</code> directory of the war file. If this
   fileset includes a file named <code>web.xml</code>, the file is
   ignored and you will get a warning.</p>
  +<h4>prefixedfileset</h4>
  +<p>The nested <code>prefixedfileset</code> element specifies a <a
  +href="#fileset">FileSet</a> with an additional prefix attribute. All
  +files included in this fileset will end up in the <em>prefix</em>
  +directory of the war file, where <em>prefix</em> is the value of the
  +<code>prefix</code> attribute.</p>
  +<table border="1" cellpadding="2" cellspacing="0">
  +  <tr>
  +    <td valign="top"><b>Attribute</b></td>
  +    <td valign="top"><b>Description</b></td>
  +    <td align="center" valign="top"><b>Required</b></td>
  +  </tr>
  +  <tr>
  +    <td valign="top">prefix</td>
  +    <td valign="top">The prefix directory to add to each filename when
  +      adding it to the archive. Default is none.</td>
  +    <td valign="top" align="center">No</td>
  +  </tr>
  +  <tr>
  +    <td valign="top">dir</td>
  +    <td valign="top">The root of the directory tree of this FileSet.</td>
  +    <td valign="top" align="center">Yes</td>
  +  </tr>
  +  <tr>
  +    <td valign="top">defaultexcludes</td>
  +    <td valign="top">indicates whether default excludes should be used or not
  +      (&quot;yes&quot;/&quot;no&quot;). Default excludes are used when
omitted.</td>
  +    <td valign="top" align="center">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>
  +    <td valign="top" align="center">No</td>
  +  </tr>
  +  <tr>
  +    <td valign="top">includesfile</td>
  +    <td valign="top">the name of a file. Each line of this file is
  +      taken to be an include pattern</td>
  +    <td valign="top" align="center">No</td>
  +  </tr>
  +  <tr>
  +    <td valign="top">excludes</td>
  +    <td valign="top">comma separated list of patterns of files that must be
  +      excluded. No files (except default excludes) are excluded when omitted.</td>
  +    <td valign="top" align="center">No</td>
  +  </tr>
  +  <tr>
  +    <td valign="top">excludesfile</td>
  +    <td valign="top">the name of a file. Each line of this file is
  +      taken to be an exclude pattern</td>
  +    <td valign="top" align="center">No</td>
  +  </tr>
  +</table>
   <h3>Examples</h3>
   <p>Assume the following structure in the project's base directory:
   <pre>
  @@ -4315,6 +4372,8 @@
   src/metadata/myapp.xml
   src/html/myapp/index.html
   src/jsp/myapp/front.jsp
  +src/graphics/images/gifs/small/logo.gif
  +src/graphics/images/gifs/large/logo.gif
   </pre>
   then the war file <code>myapp.war</code> created with
   <pre>
  @@ -4325,6 +4384,8 @@
       &lt;exclude name=&quot;jdbc1.jar&quot; /&gt;
     &lt;/lib&gt;
     &lt;classes dir=&quot;build/main&quot; /&gt;
  +  &lt;prefixedfileset dir=&quot;src/graphics/images/gifs&quot; 
  +                   prefix="images"/&gt;
   &lt;/war&gt;
   </pre>
   will consist of
  @@ -4335,6 +4396,8 @@
   META-INF/MANIFEST.MF
   index.html
   front.jsp
  +images/small/logo.gif
  +images/large/logo.gif
   </pre>
   using Ant's default manifest file. The content of
   <code>WEB-INF/web.xml</code> is identical to
  
  
  
  1.3       +46 -2     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/War.java
  
  Index: War.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/War.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- War.java	2000/09/19 14:29:44	1.2
  +++ War.java	2000/10/31 13:53:06	1.3
  @@ -64,7 +64,7 @@
   /**
    * Creates a WAR archive.
    * 
  - * @author <a href="mailto:stefan.bodewig@megabit.net">Stefan Bodewig</a> 
  + * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a> 
    */
   public class War extends Jar {
   
  @@ -73,6 +73,7 @@
       private Vector libFileSets = new Vector();
       private Vector classesFileSets = new Vector();
       private Vector webInfFileSets = new Vector();
  +    private Vector locFileSets = new Vector();
   
       public War() {
           super();
  @@ -101,6 +102,24 @@
       }
   
       /**
  +     * FileSet with an additional prefix attribute to specify the
  +     * location we want to move the files to (inside the archive).
  +     */
  +    public static class PrefixedFileSet extends FileSet {
  +        private String prefix = "";
  +
  +        public void setPrefix(String loc) {
  +            prefix = loc;
  +        }
  +
  +        public String getPrefix() {return prefix;}
  +    }
  +
  +    public void addPrefixedFileSet(PrefixedFileSet fs) {
  +        locFileSets.addElement(fs);
  +    }
  +
  +    /**
        * Add the deployment descriptor as well as all files added the
        * special way of nested lib, classes or webinf filesets.  
        */
  @@ -119,6 +138,7 @@
           addFiles(libFileSets, zOut, "WEB-INF/lib/");
           addFiles(classesFileSets, zOut, "WEB-INF/classes/");
           addFiles(webInfFileSets, zOut, "WEB-INF/");
  +        addPrefixedFiles(locFileSets, zOut);
   
           super.initZipOutputStream(zOut);
        }
  @@ -136,7 +156,8 @@
                                                     + 1 // web.xml
                                                     + libFileSets.size()
                                                     + classesFileSets.size()
  -                                                  + webInfFileSets.size()];
  +                                                  + webInfFileSets.size()
  +                                                  + locFileSets.size()];
   
           System.arraycopy(scanners, 0, myScanners, 0, scanners.length);
   
  @@ -151,6 +172,9 @@
                       classesFileSets);
           addScanners(myScanners, scanners.length+1+libFileSets.size()+classesFileSets.size(),

                       webInfFileSets);
  +        addScanners(myScanners, scanners.length + 1 + libFileSets.size()
  +                                +classesFileSets.size()+webInfFileSets.size(), 
  +                    locFileSets);
   
           return super.isUpToDate(myScanners, zipFile);
       }
  @@ -188,6 +212,26 @@
           for (int i=0; i<v.size(); i++) {
               FileSet fs = (FileSet) v.elementAt(i);
               DirectoryScanner ds = fs.getDirectoryScanner(project);
  +            addFiles(ds, zOut, prefix);
  +        }
  +    }
  +
  +    /**
  +     * Iterate over the given Vector of relocatablefilesets and add
  +     * all files to the ZipOutputStream using the given prefix.
  +     */
  +    protected void addPrefixedFiles(Vector v, ZipOutputStream zOut)
  +        throws IOException {
  +        for (int i=0; i<v.size(); i++) {
  +            PrefixedFileSet fs = (PrefixedFileSet) v.elementAt(i);
  +            DirectoryScanner ds = fs.getDirectoryScanner(project);
  +            String prefix = fs.getPrefix();
  +            if (prefix.length() > 0 
  +                && !prefix.endsWith("/")
  +                && !prefix.endsWith("\\")) {
  +                prefix += "/";
  +            }
  +            zipDir(null, zOut, prefix);
               addFiles(ds, zOut, prefix);
           }
       }
  
  
  
  1.10      +1 -1      jakarta-ant/src/main/org/apache/tools/ant/types/FileSet.java
  
  Index: FileSet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/types/FileSet.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- FileSet.java	2000/09/15 11:41:19	1.9
  +++ FileSet.java	2000/10/31 13:53:07	1.10
  @@ -71,7 +71,7 @@
    * @author Stefano Mazzocchi <a href="mailto:stefano@apache.org">stefano@apache.org</a>
    * @author Sam Ruby <a href="mailto:rubys@us.ibm.com">rubys@us.ibm.com</a>
    * @author Jon S. Stevens <a href="mailto:jon@clearink.com">jon@clearink.com</a>
  - * @author <a href="mailto:stefan.bodewig@megabit.net">Stefan Bodewig</a>
  + * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
    */
   public class FileSet extends DataType {
       
  
  
  

Mime
View raw message