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 Delete.java DependSet.java Ear.java War.java
Date Thu, 11 Apr 2002 12:29:43 GMT
bodewig     02/04/11 05:29:43

  Modified:    src/main/org/apache/tools/ant/taskdefs Delete.java
                        DependSet.java Ear.java War.java
  Log:
  Make <delete> aware of nested <includesfile> and <excludesfile>
  elements for the implicit fileset.
  
  Cosmetics.
  
  Revision  Changes    Path
  1.27      +52 -20    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Delete.java
  
  Index: Delete.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Delete.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- Delete.java	3 Mar 2002 01:46:20 -0000	1.26
  +++ Delete.java	11 Apr 2002 12:29:43 -0000	1.27
  @@ -77,6 +77,8 @@
    * @author Glenn McAllister <a href="mailto:glennm@ca.ibm.com">glennm@ca.ibm.com</a>
    * @author Jon S. Stevens <a href="mailto:jon@latchkey.com">jon@latchkey.com</a>
    *
  + * @since 1.2
  + *
    * @ant.task category="filesystem"
    */
   public class Delete extends MatchingTask {
  @@ -84,7 +86,8 @@
       protected File dir = null;
       protected Vector filesets = new Vector();
       protected boolean usedMatchingTask = false;
  -    protected boolean includeEmpty = false;     // by default, remove matching empty dirs
  +    // by default, remove matching empty dirs
  +    protected boolean includeEmpty = false;
   
       private int verbosity = Project.MSG_VERBOSE;
       private boolean quiet = false;
  @@ -169,6 +172,14 @@
       }
   
       /**
  +     * add a name entry on the include files list
  +     */
  +    public PatternSet.NameEntry createIncludesFile() {
  +        usedMatchingTask = true;
  +        return super.createIncludesFile();
  +    }
  +    
  +    /**
        * add a name entry on the exclude list
        */
       public PatternSet.NameEntry createExclude() {
  @@ -177,6 +188,14 @@
       }
   
       /**
  +     * add a name entry on the include files list
  +     */
  +    public PatternSet.NameEntry createExcludesFile() {
  +        usedMatchingTask = true;
  +        return super.createExcludesFile();
  +    }
  +    
  +    /**
        * add a set of patterns
        */
       public PatternSet createPatternSet() {
  @@ -245,16 +264,19 @@
        */
       public void execute() throws BuildException {
           if (usedMatchingTask) {
  -            log("DEPRECATED - Use of the implicit FileSet is deprecated.  Use a nested
fileset element instead.");
  +            log("DEPRECATED - Use of the implicit FileSet is deprecated.  "
  +                + "Use a nested fileset element instead.");
           }
   
           if (file == null && dir == null && filesets.size() == 0) {
  -            throw new BuildException("At least one of the file or dir attributes, or a
fileset element, must be set.");
  +            throw new BuildException("At least one of the file or dir "
  +                                     + "attributes, or a fileset element, "
  +                                     + "must be set.");
           }
   
           if (quiet && failonerror) {
  -            throw new BuildException("quiet and failonerror cannot both be set to true",
  -                                     location);
  +            throw new BuildException("quiet and failonerror cannot both be "
  +                                     + "set to true", location);
           }
           
   
  @@ -262,33 +284,39 @@
           if (file != null) {
               if (file.exists()) {
                   if (file.isDirectory()) {
  -                    log("Directory " + file.getAbsolutePath() + " cannot be removed using
the file attribute.  Use dir instead.");
  +                    log("Directory " + file.getAbsolutePath() 
  +                        + " cannot be removed using the file attribute.  "
  +                        + "Use dir instead.");
                   } else {
                       log("Deleting: " + file.getAbsolutePath());
   
                       if (!file.delete()) {
  -                        String message="Unable to delete file " + file.getAbsolutePath();
  +                        String message="Unable to delete file " 
  +                            + file.getAbsolutePath();
                           if(failonerror) {
                               throw new BuildException(message);
                           } else { 
  -                            log(message, 
  -                                quiet ? Project.MSG_VERBOSE : Project.MSG_WARN);
  +                            log(message, quiet ? Project.MSG_VERBOSE 
  +                                               : Project.MSG_WARN);
                           }
                       }
                   }
               } else {
  -                log("Could not find file " + file.getAbsolutePath() + " to delete.", 
  +                log("Could not find file " + file.getAbsolutePath() 
  +                    + " to delete.", 
                       Project.MSG_VERBOSE);
               }
           }
   
           // delete the directory
  -        if (dir != null && dir.exists() && dir.isDirectory() &&
!usedMatchingTask) {
  +        if (dir != null && dir.exists() && dir.isDirectory() &&

  +            !usedMatchingTask) {
               /*
  -               If verbosity is MSG_VERBOSE, that mean we are doing regular logging
  -               (backwards as that sounds).  In that case, we want to print one
  -               message about deleting the top of the directory tree.  Otherwise,
  -               the removeDir method will handle messages for _all_ directories.
  +               If verbosity is MSG_VERBOSE, that mean we are doing
  +               regular logging (backwards as that sounds).  In that
  +               case, we want to print one message about deleting the
  +               top of the directory tree.  Otherwise, the removeDir
  +               method will handle messages for _all_ directories.
                */
               if (verbosity == Project.MSG_VERBOSE) {
                   log("Deleting directory " + dir.getAbsolutePath());
  @@ -341,7 +369,7 @@
       protected void removeDir(File d) {
           String[] list = d.list();
           if (list == null) {
  -          list = new String[0];
  +            list = new String[0];
           }
           for (int i = 0; i < list.length; i++) {
               String s = list[i];
  @@ -351,7 +379,8 @@
               } else {
                   log("Deleting " + f.getAbsolutePath(), verbosity);
                   if (!f.delete()) {
  -                    String message="Unable to delete file " + f.getAbsolutePath();
  +                    String message="Unable to delete file " 
  +                        + f.getAbsolutePath();
                       if(failonerror) {
                           throw new BuildException(message);
                       } else {
  @@ -363,7 +392,8 @@
           }
           log("Deleting directory " + d.getAbsolutePath(), verbosity);
           if (!d.delete()) {
  -            String message="Unable to delete directory " + dir.getAbsolutePath();
  +            String message="Unable to delete directory " 
  +                + dir.getAbsolutePath();
               if(failonerror) {
                   throw new BuildException(message);
               } else {
  @@ -382,12 +412,14 @@
        */
       protected void removeFiles(File d, String[] files, String[] dirs) {
           if (files.length > 0) {
  -            log("Deleting " + files.length + " files from " + d.getAbsolutePath());
  +            log("Deleting " + files.length + " files from " 
  +                + d.getAbsolutePath());
               for (int j=0; j<files.length; j++) {
                   File f = new File(d, files[j]);
                   log("Deleting " + f.getAbsolutePath(), verbosity);
                   if (!f.delete()) {
  -                    String message="Unable to delete file " + f.getAbsolutePath();
  +                    String message="Unable to delete file " 
  +                        + f.getAbsolutePath();
                       if(failonerror) {
                           throw new BuildException(message);
                       } else {
  
  
  
  1.12      +13 -9     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/DependSet.java
  
  Index: DependSet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/DependSet.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- DependSet.java	3 Mar 2002 01:46:20 -0000	1.11
  +++ DependSet.java	11 Apr 2002 12:29:43 -0000	1.12
  @@ -109,7 +109,8 @@
    * 
    * @author <a href="mailto:cstrong@arielpartners.com">Craeg Strong</a>
    * @ant.task category="filesystem"
  - * @version $Revision: 1.11 $ $Date: 2002/03/03 01:46:20 $
  + * @version $Revision: 1.12 $ $Date: 2002/04/11 12:29:43 $
  + * @since Ant 1.4
    */
   public class DependSet extends MatchingTask {
   
  @@ -159,11 +160,13 @@
       public void execute() throws BuildException {
   
           if ( (sourceFileSets.size() == 0) && (sourceFileLists.size() == 0) ) {

  -          throw new BuildException("At least one <srcfileset> or <srcfilelist>
element must be set");
  +          throw new BuildException("At least one <srcfileset> or <srcfilelist>"
  +                                   + " element must be set");
           }
   
           if ( (targetFileSets.size() == 0) && (targetFileLists.size() == 0) ) {
  -          throw new BuildException("At least one <targetfileset> or <targetfilelist>
element must be set");
  +          throw new BuildException("At least one <targetfileset> or"
  +                                   + " <targetfilelist> element must be set");
           }
   
           long now = (new Date()).getTime();
  @@ -255,8 +258,8 @@
              Enumeration enumSourceLists = sourceFileLists.elements();
              while (upToDate && enumSourceLists.hasMoreElements()) {
             
  -              FileList sourceFL         = (FileList) enumSourceLists.nextElement();
  -              String[] sourceFiles      = sourceFL.getFiles(project);
  +              FileList sourceFL    = (FileList) enumSourceLists.nextElement();
  +              String[] sourceFiles = sourceFL.getFiles(project);
   
                 for (int i=0; upToDate && i < sourceFiles.length; i++) {
                    File src = new File(sourceFL.getDir(project), sourceFiles[i]);
  @@ -267,7 +270,8 @@
                    }
   
                    if (!src.exists()) {
  -                    log(sourceFiles[i]+ " does not exist.", Project.MSG_VERBOSE);
  +                    log(sourceFiles[i]+ " does not exist.", 
  +                        Project.MSG_VERBOSE);
                       upToDate = false;
                       break;
                    }
  @@ -288,7 +292,7 @@
              Enumeration enumSourceSets = sourceFileSets.elements();
              while (upToDate && enumSourceSets.hasMoreElements()) {
             
  -              FileSet sourceFS          = (FileSet) enumSourceSets.nextElement();
  +              FileSet sourceFS         = (FileSet) enumSourceSets.nextElement();
                 DirectoryScanner sourceDS = sourceFS.getDirectoryScanner(project);
                 String[] sourceFiles      = sourceDS.getIncludedFiles();
   
  @@ -313,11 +317,11 @@
              log("Deleting all target files. ", Project.MSG_VERBOSE);
              for (Enumeration e = allTargets.elements(); e.hasMoreElements(); ) {
                 File fileToRemove = (File)e.nextElement();
  -              log("Deleting file " + fileToRemove.getAbsolutePath(), Project.MSG_VERBOSE);
  +              log("Deleting file " + fileToRemove.getAbsolutePath(), 
  +                  Project.MSG_VERBOSE);
                 fileToRemove.delete();
              }
           }
  -        
   
       } //-- execute
      
  
  
  
  1.12      +19 -12    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Ear.java
  
  Index: Ear.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Ear.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- Ear.java	15 Mar 2002 02:36:33 -0000	1.11
  +++ Ear.java	11 Apr 2002 12:29:43 -0000	1.12
  @@ -61,13 +61,14 @@
   import java.io.File;
   import java.io.IOException;
   
  -
   /**
    * Creates a EAR archive. Based on WAR task
    *
    * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
    * @author <a href="mailto:leslie.hughes@rubus.com">Les Hughes</a>
    *
  + * @since Ant 1.4
  + *
    * @ant.task category="packaging"
    */
   public class Ear extends Jar {
  @@ -94,7 +95,9 @@
       public void setAppxml(File descr) {
           deploymentDescriptor = descr;
           if (!deploymentDescriptor.exists()) {
  -            throw new BuildException("Deployment descriptor: " + deploymentDescriptor +
" does not exist.");
  +            throw new BuildException("Deployment descriptor: " 
  +                                     + deploymentDescriptor 
  +                                     + " does not exist.");
           }
   
           // Create a ZipFileSet for this file, and pass it up.
  @@ -109,7 +112,6 @@
       public void addArchives(ZipFileSet fs) {
           // We just set the prefix for this fileset, and pass it up.
           // Do we need to do this? LH
  -        log("addArchives called",Project.MSG_DEBUG);
           fs.setPrefix("/");
           super.addFileset(fs);
       }
  @@ -129,14 +131,19 @@
       protected void zipFile(File file, ZipOutputStream zOut, String vPath)
           throws IOException
       {
  -        // If the file being added is META-INF/application.xml, we warn if it's not the
  -        // one specified in the "appxml" attribute - or if it's being added twice,
  -        // meaning the same file is specified by the "appxml" attribute and in
  -        // a <fileset> element.
  +        // If the file being added is META-INF/application.xml, we
  +        // warn if it's not the one specified in the "appxml"
  +        // attribute - or if it's being added twice, meaning the same
  +        // file is specified by the "appxml" attribute and in a
  +        // <fileset> element.
           if (vPath.equalsIgnoreCase("META-INF/application.xml"))  {
  -            if (deploymentDescriptor == null || !deploymentDescriptor.equals(file) || descriptorAdded)
{
  -                log("Warning: selected "+archiveType+" files include a META-INF/application.xml
which will be ignored " +
  -                    "(please use appxml attribute to "+archiveType+" task)", Project.MSG_WARN);
  +            if (deploymentDescriptor == null 
  +                || !deploymentDescriptor.equals(file) 
  +                || descriptorAdded) {
  +                log("Warning: selected "+archiveType
  +                    + " files include a META-INF/application.xml which will"
  +                    + " be ignored (please use appxml attribute to "
  +                    + archiveType + " task)", Project.MSG_WARN);
               } else {
                   super.zipFile(file, zOut, vPath);
                   descriptorAdded = true;
  @@ -147,8 +154,8 @@
       }
   
       /**
  -     * Make sure we don't think we already have a application.xml next time this task
  -     * gets executed.
  +     * Make sure we don't think we already have a application.xml next
  +     * time this task gets executed.
        */
       protected void cleanUp() {
           descriptorAdded = false;
  
  
  
  1.22      +16 -8     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.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- War.java	15 Mar 2002 02:36:33 -0000	1.21
  +++ War.java	11 Apr 2002 12:29:43 -0000	1.22
  @@ -68,6 +68,8 @@
    *
    * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
    *
  + * @since Ant 1.2
  + *
    * @ant.task category="packaging"
    */
   public class War extends Jar {
  @@ -94,7 +96,9 @@
       public void setWebxml(File descr) {
           deploymentDescriptor = descr;
           if (!deploymentDescriptor.exists()) {
  -            throw new BuildException("Deployment descriptor: " + deploymentDescriptor +
" does not exist.");
  +            throw new BuildException("Deployment descriptor: " 
  +                                     + deploymentDescriptor 
  +                                     + " does not exist.");
           }
   
           // Create a ZipFileSet for this file, and pass it up.
  @@ -137,14 +141,18 @@
       protected void zipFile(File file, ZipOutputStream zOut, String vPath)
           throws IOException
       {
  -        // If the file being added is WEB-INF/web.xml, we warn if it's not the
  -        // one specified in the "webxml" attribute - or if it's being added twice,
  -        // meaning the same file is specified by the "webxml" attribute and in
  -        // a <fileset> element.
  +        // If the file being added is WEB-INF/web.xml, we warn if it's
  +        // not the one specified in the "webxml" attribute - or if
  +        // it's being added twice, meaning the same file is specified
  +        // by the "webxml" attribute and in a <fileset> element.
           if (vPath.equalsIgnoreCase("WEB-INF/web.xml"))  {
  -            if (deploymentDescriptor == null || !deploymentDescriptor.equals(file) || descriptorAdded)
{
  -                log("Warning: selected "+archiveType+" files include a WEB-INF/web.xml
which will be ignored " +
  -                    "(please use webxml attribute to "+archiveType+" task)", Project.MSG_WARN);
  +            if (deploymentDescriptor == null 
  +                || !deploymentDescriptor.equals(file) 
  +                || descriptorAdded) {
  +                log("Warning: selected " + archiveType
  +                    + " files include a WEB-INF/web.xml which will be ignored "
  +                    + "(please use webxml attribute to "
  +                    + archiveType + " task)", Project.MSG_WARN);
               } else {
                   super.zipFile(file, zOut, vPath);
                   descriptorAdded = true;
  
  
  

--
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