ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: ant/src/main/org/apache/tools/ant/taskdefs/optional Cab.java
Date Wed, 19 Mar 2003 10:48:01 GMT
bodewig     2003/03/19 02:48:01

  Modified:    .        WHATSNEW
               docs/manual/OptionalTasks cab.html
               src/main/org/apache/tools/ant/taskdefs/optional Cab.java
  Log:
  Make <cab>'s basedir optional.
  
  PR: 18046
  
  Revision  Changes    Path
  1.368     +3 -0      ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/ant/WHATSNEW,v
  retrieving revision 1.367
  retrieving revision 1.368
  diff -u -r1.367 -r1.368
  --- WHATSNEW	19 Mar 2003 10:09:38 -0000	1.367
  +++ WHATSNEW	19 Mar 2003 10:48:01 -0000	1.368
  @@ -169,6 +169,9 @@
   
   * Support for HP's NonStop (Tandem) OS has been added.
   
  +* <cab>'s basedir attribute is now optional if you specify nested
  +  filesets.  Bugzilla Report 18046.
  +
   Changes from Ant 1.5.2 to Ant 1.5.3
   ===================================
   
  
  
  
  1.8       +22 -2     ant/docs/manual/OptionalTasks/cab.html
  
  Index: cab.html
  ===================================================================
  RCS file: /home/cvs/ant/docs/manual/OptionalTasks/cab.html,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- cab.html	22 Jun 2002 23:38:28 -0000	1.7
  +++ cab.html	19 Mar 2003 10:48:01 -0000	1.8
  @@ -39,7 +39,7 @@
     <tr>
       <td valign="top">basedir</td>
       <td valign="top">the directory to start archiving files from.</td>
  -    <td valign="top" align="center">Yes</td>
  +    <td valign="top" align="center">No</td>
     </tr>
     <tr>
       <td valign="top">verbose</td>
  @@ -91,6 +91,13 @@
       <td valign="top" align="center">No</td>
     </tr>
   </table>
  +<h3>Parameters specified as nested elements</h3>
  +<h4>fileset</h4>
  +
  +<p>The cab task supports any number of nested <a
  +href="../CoreTypes/fileset.html"><code>&lt;fileset&gt;</code></a>
  +elements to specify the files to be included in the archive.</p>
  +
   <h3>Examples</h3>
   <blockquote><pre>
   &lt;cab cabfile=&quot;${dist}/manual.cab&quot;
  @@ -121,8 +128,21 @@
   directory api are archived, and files with the name todo.html are
   excluded. Output from the cabarc tool is displayed in the build
   output.</p>
  +
  +<blockquote><pre>
  +&lt;cab cabfile=&quot;${dist}/manual.cab&quot;
  +     verbose=&quot;yes&quot;&gt;
  +  &lt;fileset
  +       dir=&quot;htdocs/manual&quot;
  +       includes=&quot;api/**/*.html&quot;
  +       excludes=&quot;**/todo.html&quot;
  +  /&gt;
  +&lt;/cab&gt;
  +</pre></blockquote>
  +<p>is equivalent to the example above.</p>
  +
   <hr>
  -<p align="center">Copyright &copy; 2000-2002 Apache Software Foundation. All
rights
  +<p align="center">Copyright &copy; 2000-2003 Apache Software Foundation. All
rights
   Reserved.</p>
   
   </body>
  
  
  
  1.25      +20 -15    ant/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java
  
  Index: Cab.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- Cab.java	10 Feb 2003 14:13:45 -0000	1.24
  +++ Cab.java	19 Mar 2003 10:48:01 -0000	1.25
  @@ -1,7 +1,7 @@
   /*
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2000-2002 The Apache Software Foundation.  All rights
  + * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -143,14 +143,17 @@
        * for side-effects to me...
        */
       protected void checkConfiguration() throws BuildException {
  -        if (baseDir == null) {
  -            throw new BuildException("basedir attribute must be set!", getLocation());
  +        if (baseDir == null && filesets.size() == 0) {
  +            throw new BuildException("basedir attribute or at least one "
  +                                     + "nested filest is required!", 
  +                                     getLocation());
           }
  -        if (!baseDir.exists()) {
  +        if (baseDir != null && !baseDir.exists()) {
               throw new BuildException("basedir does not exist!", getLocation());
           }
           if (cabFile == null) {
  -            throw new BuildException("cabfile attribute must be set!" , getLocation());
  +            throw new BuildException("cabfile attribute must be set!",
  +                                     getLocation());
           }
       }
   
  @@ -175,7 +178,7 @@
           boolean upToDate = true;
           for (int i = 0; i < files.size() && upToDate; i++) {
               String file = files.elementAt(i).toString();
  -            if (new File(baseDir, file).lastModified() >
  +            if (fileUtils.resolveFile(baseDir, file).lastModified() >
                   cabFile.lastModified()) {
                   upToDate = false;
               }
  @@ -220,16 +223,16 @@
       protected Vector getFileList() throws BuildException {
           Vector files = new Vector();
   
  -        if (filesets.size() == 0) {
  +        if (baseDir != null) {
               // get files from old methods - includes and nested include
               appendFiles(files, super.getDirectoryScanner(baseDir));
  -        } else {
  -            // get files from filesets
  -            for (int i = 0; i < filesets.size(); i++) {
  -                FileSet fs = (FileSet) filesets.elementAt(i);
  -                if (fs != null) {
  -                    appendFiles(files, fs.getDirectoryScanner(getProject()));
  -                }
  +        }
  +
  +        // get files from filesets
  +        for (int i = 0; i < filesets.size(); i++) {
  +            FileSet fs = (FileSet) filesets.elementAt(i);
  +            if (fs != null) {
  +                appendFiles(files, fs.getDirectoryScanner(getProject()));
               }
           }
   
  @@ -264,7 +267,9 @@
               try {
                   Process p = Execute.launch(getProject(),
                                              new String[] {"listcab"}, null,
  -                                           baseDir, true);
  +                                           baseDir != null ? baseDir 
  +                                                   : getProject().getBaseDir(),
  +                                           true);
                   OutputStream out = p.getOutputStream();
   
                   // Create the stream pumpers to forward listcab's stdout and stderr to
the log
  
  
  

Mime
View raw message