ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anto...@apache.org
Subject cvs commit: ant/docs/manual/CoreTasks defaultexcludes.html
Date Mon, 21 Jul 2003 10:52:20 GMT
antoine     2003/07/21 03:52:20

  Modified:    src/main/org/apache/tools/ant DirectoryScanner.java
               src/main/org/apache/tools/ant/taskdefs DefaultExcludes.java
               src/etc/testcases/taskdefs defaultexcludes.xml
               src/testcases/org/apache/tools/ant/taskdefs
                        DefaultExcludesTest.java
               docs/manual/CoreTasks defaultexcludes.html
  Log:
  Add a method in DirectoryScanner to reset the default exclude patterns
  Add corresponding functionality in <defaultexcludes>
  Update tests
  
  Revision  Changes    Path
  1.50      +14 -4     ant/src/main/org/apache/tools/ant/DirectoryScanner.java
  
  Index: DirectoryScanner.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/DirectoryScanner.java,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- DirectoryScanner.java	19 Jul 2003 17:08:06 -0000	1.49
  +++ DirectoryScanner.java	21 Jul 2003 10:52:19 -0000	1.50
  @@ -205,11 +205,8 @@
        * @see #addDefaultExcludes()
        */
       private static Vector defaultExcludes = new Vector();
  -
       static {
  -        for (int i = 0; i < DEFAULTEXCLUDES.length; i++) {
  -            defaultExcludes.add(DEFAULTEXCLUDES[i]);
  -        }
  +        resetDefaultExcludes();
       }
   
       /** The base directory to be scanned. */
  @@ -452,6 +449,19 @@
        */
       public static boolean removeDefaultExclude(String s) {
           return defaultExcludes.remove(s);
  +    }
  +
  +    /**
  +     *  Go back to the hard wired default exclude patterns
  +     *
  +     * @since Ant 1.6
  +     */
  +    public static void resetDefaultExcludes() {
  +    defaultExcludes = new Vector();
  +
  +        for (int i = 0; i < DEFAULTEXCLUDES.length; i++) {
  +            defaultExcludes.add(DEFAULTEXCLUDES[i]);
  +        }
       }
   
       /**
  
  
  
  1.5       +14 -3     ant/src/main/org/apache/tools/ant/taskdefs/DefaultExcludes.java
  
  Index: DefaultExcludes.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/DefaultExcludes.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DefaultExcludes.java	19 Jul 2003 11:20:12 -0000	1.4
  +++ DefaultExcludes.java	21 Jul 2003 10:52:19 -0000	1.5
  @@ -71,7 +71,7 @@
   public class DefaultExcludes extends Task {
       private String add = "";
       private String remove = "";
  -
  +    private boolean defaultrequested = false;
       private boolean echo = false;
   
       // by default, messages are always displayed
  @@ -83,11 +83,14 @@
        * @exception BuildException if someting goes wrong with the build
        */
       public void execute() throws BuildException {
  -        if (add.equals("") && remove.equals("") && (echo == false)) {
  +        if (defaultrequested == false && add.equals("") && remove.equals("")
&& (echo == false)) {
               throw new BuildException("<defaultexcludes> task must set "
  -                + "at least one atribute (echo=\"false\""
  +                + "at least one attribute (echo=\"false\""
                   + " doesn't count since that is the default");
           }
  +        if (defaultrequested == true) {
  +            DirectoryScanner.resetDefaultExcludes();
  +        }
           if (!add.equals("")) {
               DirectoryScanner.addDefaultExclude(add);
           }
  @@ -105,6 +108,14 @@
           }
       }
   
  +    /**
  +     * go back to standard default patterns
  +     *
  +     * @param def if true go back to default patterns
  +     */
  +    public void setDefault(boolean def) {
  +        defaultrequested = def;
  +    }
       /**
        * Pattern to add to the default excludes
        *
  
  
  
  1.2       +2 -4      ant/src/etc/testcases/taskdefs/defaultexcludes.xml
  
  Index: defaultexcludes.xml
  ===================================================================
  RCS file: /home/cvs/ant/src/etc/testcases/taskdefs/defaultexcludes.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- defaultexcludes.xml	9 May 2003 12:10:36 -0000	1.1
  +++ defaultexcludes.xml	21 Jul 2003 10:52:19 -0000	1.2
  @@ -7,13 +7,11 @@
     </target>
   
     <target name="test2">
  -    <defaultexcludes add="foo" echo="true"/>
  -    <defaultexcludes remove="foo" echo="false"/>
  +    <defaultexcludes default="true" add="foo" echo="true"/>
     </target>
   
     <target name="test3">
  -    <defaultexcludes remove="**/CVS" echo="true"/>
  -    <defaultexcludes add="**/CVS" echo="false"/>
  +    <defaultexcludes default="true" remove="**/CVS" echo="true"/>
     </target>
   
   </project>
  
  
  
  1.3       +61 -46    ant/src/testcases/org/apache/tools/ant/taskdefs/DefaultExcludesTest.java
  
  Index: DefaultExcludesTest.java
  ===================================================================
  RCS file: /home/cvs/ant/src/testcases/org/apache/tools/ant/taskdefs/DefaultExcludesTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultExcludesTest.java	17 Jul 2003 10:20:16 -0000	1.2
  +++ DefaultExcludesTest.java	21 Jul 2003 10:52:19 -0000	1.3
  @@ -55,6 +55,7 @@
   package org.apache.tools.ant.taskdefs;
   
   import org.apache.tools.ant.BuildFileTest;
  +import org.apache.tools.ant.DirectoryScanner;
   
   /**
    * @author Gus Heck <gus.heck@olin.edu>
  @@ -71,59 +72,73 @@
   
       // Output the default excludes
       public void test1() {
  -        expectLog("test1", "Current Default Excludes:\n"+
  -                  "  **/*~\n"+
  -                  "  **/#*#\n"+
  -                  "  **/.#*\n"+
  -                  "  **/%*%\n"+
  -                  "  **/._*\n"+
  -                  "  **/CVS\n"+
  -                  "  **/CVS/**\n"+
  -                  "  **/.cvsignore\n"+
  -                  "  **/SCCS\n"+
  -                  "  **/SCCS/**\n"+
  -                  "  **/vssver.scc\n"+
  -                  "  **/.svn\n"+
  -                  "  **/.svn/**\n"+
  -                  "  **/.DS_Store");
  +        String[] expected = {
  +                          "**/*~",
  +                          "**/#*#",
  +                          "**/.#*",
  +                          "**/%*%",
  +                          "**/._*",
  +                          "**/CVS",
  +                          "**/CVS/**",
  +                          "**/.cvsignore",
  +                          "**/SCCS",
  +                          "**/SCCS/**",
  +                          "**/vssver.scc",
  +                          "**/.svn",
  +                          "**/.svn/**",
  +                          "**/.DS_Store"};
  +        project.executeTarget("test1");
  +        assertEquals("current default excludes", expected, DirectoryScanner.getDefaultExcludes());
       }
   
       // adding something to the excludes'
       public void test2() {
  -        expectLog("test2", "Current Default Excludes:\n"+
  -                  "  **/*~\n"+
  -                  "  **/#*#\n"+
  -                  "  **/.#*\n"+
  -                  "  **/%*%\n"+
  -                  "  **/._*\n"+
  -                  "  **/CVS\n"+
  -                  "  **/CVS/**\n"+
  -                  "  **/.cvsignore\n"+
  -                  "  **/SCCS\n"+
  -                  "  **/SCCS/**\n"+
  -                  "  **/vssver.scc\n"+
  -                  "  **/.svn\n"+
  -                  "  **/.svn/**\n"+
  -                  "  **/.DS_Store\n"+
  -                  "  foo");             // foo added
  +        String[] expected = {
  +                          "**/*~",
  +                          "**/#*#",
  +                          "**/.#*",
  +                          "**/%*%",
  +                          "**/._*",
  +                          "**/CVS",
  +                          "**/CVS/**",
  +                          "**/.cvsignore",
  +                          "**/SCCS",
  +                          "**/SCCS/**",
  +                          "**/vssver.scc",
  +                          "**/.svn",
  +                          "**/.svn/**",
  +                          "**/.DS_Store",
  +                          "foo"};
  +        project.executeTarget("test2");
  +        assertEquals("current default excludes", expected, DirectoryScanner.getDefaultExcludes());
       }
   
       // removing something from the defaults
       public void test3() {
  -        expectLog("test3", "Current Default Excludes:\n"+
  -                  "  **/*~\n"+
  -                  "  **/#*#\n"+
  -                  "  **/.#*\n"+
  -                  "  **/%*%\n"+
  -                  "  **/._*\n"+
  -                  //CVS missing
  -                  "  **/CVS/**\n"+
  -                  "  **/.cvsignore\n"+
  -                  "  **/SCCS\n"+
  -                  "  **/SCCS/**\n"+
  -                  "  **/vssver.scc\n"+
  -                  "  **/.svn\n"+
  -                  "  **/.svn/**\n"+
  -                  "  **/.DS_Store");
  +        String[] expected = {
  +                          "**/*~",
  +                          "**/#*#",
  +                          "**/.#*",
  +                          "**/%*%",
  +                          "**/._*",
  +                          //CVS missing
  +                          "**/CVS/**",
  +                          "**/.cvsignore",
  +                          "**/SCCS",
  +                          "**/SCCS/**",
  +                          "**/vssver.scc",
  +                          "**/.svn",
  +                          "**/.svn/**",
  +                          "**/.DS_Store"};
  +        project.executeTarget("test3");
  +        assertEquals("current default excludes", expected, DirectoryScanner.getDefaultExcludes());
  +    }
  +    private void assertEquals(String message, String[] expected, String[] actual) {
  +        // check that both arrays have the same size
  +        assertEquals(message + " : string array length match", expected.length, actual.length);
  +        for (int counter=0; counter <expected.length; counter++) {
  +            assertEquals(message + " : " + counter + "th element in array match", expected[counter],
actual[counter]);
  +        }
  +
       }
   }
  
  
  
  1.2       +11 -5     ant/docs/manual/CoreTasks/defaultexcludes.html
  
  Index: defaultexcludes.html
  ===================================================================
  RCS file: /home/cvs/ant/docs/manual/CoreTasks/defaultexcludes.html,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- defaultexcludes.html	9 May 2003 12:10:35 -0000	1.1
  +++ defaultexcludes.html	21 Jul 2003 10:52:20 -0000	1.2
  @@ -25,18 +25,24 @@
     <tr>
       <td valign="top">echo</td>
       <td valign="top">whether or not to print out the default excludes.(defaults to
false)</td>
  -    <td valign="top" align="center">atribute "true" required if no 
  -                                    other argument specified</td>
  +    <td valign="top" align="center">attribute "true" required if no
  +                                    other attribute specified</td>
  +  </tr>
  +  <tr>
  +    <td valign="top">default</td>
  +    <td valign="top">go back to hard wired default excludes</td>
  +    <td valign="top" align="center">attribute "true" required if no
  +    if no other attribute is specified</td>
     </tr>
     <tr>
       <td valign="top">add</td>
       <td valign="top">the pattern to add to the default excludes</td>
  -    <td valign="top" align="center">if no other atribute is specified</td>
  +    <td valign="top" align="center">if no other attribute is specified</td>
     </tr>
     <tr>
       <td valign="top">remove</td>
       <td valign="top">remove the specified pattern from the default excludes</td>
  -    <td valign="top" align="center">if no other atribute is specified</td>
  +    <td valign="top" align="center">if no other attribute is specified</td>
     </tr>
   </table>
   
  @@ -59,7 +65,7 @@
   
     (do several fileset based tasks here)
   
  -  &lt;defaultexcludes add=&quot;**/*~&quot;/&gt;
  +  &lt;defaultexcludes default=&quot;true&quot;/&gt;
   </pre>
   
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message