ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peterrei...@apache.org
Subject cvs commit: ant/src/etc/testcases/types filelist.xml
Date Mon, 23 Feb 2004 16:40:55 GMT
peterreilly    2004/02/23 08:40:55

  Modified:    src/main/org/apache/tools/ant/types FileList.java
               docs/manual/CoreTypes filelist.html
               src/testcases/org/apache/tools/ant/types FileListTest.java
  Added:       src/etc/testcases/types filelist.xml
  Log:
  Add nested file element to file list to allow filenames to
  contain white space and commas
  
  Revision  Changes    Path
  1.15      +35 -0     ant/src/main/org/apache/tools/ant/types/FileList.java
  
  Index: FileList.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/FileList.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- FileList.java	23 Feb 2004 15:42:24 -0000	1.14
  +++ FileList.java	23 Feb 2004 16:40:55 -0000	1.15
  @@ -159,4 +159,39 @@
           }
       }
   
  +    /**
  +     * Inner class corresponding to the <file> nested element.
  +     */
  +    public static class FileName {
  +        private String name;
  +
  +        /**
  +         * The name attribute of the file element.
  +         *
  +         * @param name the name of a file to add to the file list.
  +         */
  +        public void setName(String name) {
  +            this.name = name;
  +        }
  +
  +        /**
  +         * @return the name of the file for this element.
  +         */
  +        public String getName() {
  +            return name;
  +        }
  +    }
  +
  +    /**
  +     * Add a nested <file> nested element.
  +     *
  +     * @param name a configured file element with a name.
  +     */
  +    public void addConfiguredFile(FileName name) {
  +        if (name.getName() == null) {
  +            throw new BuildException(
  +                "No name specified in nested file element");
  +        }
  +        filenames.addElement(name.getName());
  +    }
   }
  
  
  
  1.9       +35 -6     ant/docs/manual/CoreTypes/filelist.html
  
  Index: filelist.html
  ===================================================================
  RCS file: /home/cvs/ant/docs/manual/CoreTypes/filelist.html,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- filelist.html	9 Feb 2004 21:50:07 -0000	1.8
  +++ filelist.html	23 Feb 2004 16:40:55 -0000	1.9
  @@ -16,9 +16,8 @@
   specified as a list of files, relative to the specified directory,
   with no support for wildcard expansion (filenames with wildcards will be
   included in the list unchanged).
  -FileLists can appear inside tasks that support this feature or at the
  -same level as <code>&lt;target&gt;</code> (i.e., as children of
  -<code>&lt;project&gt;</code>).
  +FileLists can appear inside tasks that support this feature or as stand-alone
  +types.
   </p>
   <table border="1" cellpadding="2" cellspacing="0">
     <tr>
  @@ -33,11 +32,30 @@
     </tr>
     <tr>
       <td valign="top">files</td>
  -    <td valign="top">The list of file names.</td>
  -    <td valign="top" align="center">Yes</td>
  +    <td valign="top">The list of file names. This is a list of
  +    file name separated by whitespace, or by commas.</td>
  +    <td valign="top" align="center">
  +      Yes, unless there is a nested file element</td>
     </tr>
   </table>
  -
  +  <h4>Nested Element: file</h4>
  +  <p>
  +    This represents a file name. The nested element allows filenames containing
  +    white space and commas.
  +  </p>
  +  <p><em>Since ant 1.7</em></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">name</td>
  +      <td valign="top">The name of the file.</td>
  +      <td valign="top" align="center">Yes</td>
  +    </tr>
  +</table>  
   <h4>Examples</h4>
   <blockquote><pre>
   &lt;filelist 
  @@ -63,6 +81,17 @@
   
   <blockquote><pre>
   &lt;filelist refid=&quot;docfiles&quot;/&gt; 
  +</pre></blockquote>
  +
  +<p>Same files as the example above.</p>
  +
  +<blockquote><pre>
  +&lt;filelist 
  +    id=&quot;docfiles&quot; 
  +    dir=&quot;${doc.src}&quot;&gt;
  +    &lt;file name="foo.xml"/&gt;
  +    &lt;file name="bar.xml"/&gt;
  +&lt;/filelist&gt;
   </pre></blockquote>
   
   <p>Same files as the example above.</p>
  
  
  
  1.6       +18 -13    ant/src/testcases/org/apache/tools/ant/types/FileListTest.java
  
  Index: FileListTest.java
  ===================================================================
  RCS file: /home/cvs/ant/src/testcases/org/apache/tools/ant/types/FileListTest.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- FileListTest.java	9 Feb 2004 21:05:45 -0000	1.5
  +++ FileListTest.java	23 Feb 2004 16:40:55 -0000	1.6
  @@ -17,8 +17,9 @@
   
   package org.apache.tools.ant.types;
   
  -import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.Project;
  +import org.apache.tools.ant.BuildException;
  +import org.apache.tools.ant.BuildFileTest;
   
   import junit.framework.TestCase;
   import junit.framework.AssertionFailedError;
  @@ -26,27 +27,19 @@
   import java.io.File;
   
   /**
  - * JUnit 3 testcases for org.apache.tools.ant.types.FileList.
  - *
  - * <p>This doesn't actually test much, mainly reference handling.
  - * Adapted from FileSetTest.</p>
  - *
  - * @author <a href="mailto:cstrong@arielpartners.com">Craeg Strong</a>
  + * Some tests for filelist.
    */
   
  -public class FileListTest extends TestCase {
  -
  -    private Project project;
  +public class FileListTest extends BuildFileTest {
   
       public FileListTest(String name) {
           super(name);
       }
   
       public void setUp() {
  -        project = new Project();
  -        project.setBasedir(".");
  +        configureProject("src/etc/testcases/types/filelist.xml");
       }
  -
  +    
       public void testEmptyElementIfIsReference() {
           FileList f = new FileList();
           f.setDir(project.resolveFile("."));
  @@ -143,5 +136,17 @@
           f3.setDir(project.resolveFile("."));
           File dir = f1.getDir(project);
           assertEquals("Dir is basedir", dir, project.getBaseDir());
  +    }
  +    
  +    public void testSimple() {
  +        expectLog("simple", "/abc/a");
  +    }
  +
  +    public void testDouble() {
  +        expectLog("double", "/abc/a:/abc/b");
  +    }
  +
  +    public void testNested() {
  +        expectLog("nested", "/abc/a:/abc/b");
       }
   }
  
  
  
  1.1                  ant/src/etc/testcases/types/filelist.xml
  
  Index: filelist.xml
  ===================================================================
  <project name="test">
    <target name="simple">
      <filelist id="filelist"
                dir="${basedir}"
                files="a"/>
      <pathconvert targetos="unix" refid="filelist"
                   property="property">
        <map from="${basedir}" to="/abc"/>
      </pathconvert>
      <echo>${property}</echo>
    </target>
  
    <target name="double">
      <filelist id="filelist"
                dir="${basedir}"
                files="a b"/>
      <pathconvert targetos="unix" refid="filelist"
                   property="property">
        <map from="${basedir}" to="/abc"/>
      </pathconvert>
      <echo>${property}</echo>
    </target>
  
    <target name="nested">
      <filelist id="filelist"
                dir="${basedir}">
        <file name="a"/>
        <file name="b"/>
      </filelist>
      <pathconvert targetos="unix" refid="filelist"
                   property="property">
        <map from="${basedir}" to="/abc"/>
      </pathconvert>
      <echo>${property}</echo>
    </target>
  
  </project>
  
  
  

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


Mime
View raw message