ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <jakarta-...@ehatchersolutions.com>
Subject Re: [PATCH] Commandline.Argument now supports nested FileSets
Date Tue, 20 Aug 2002 19:55:33 GMT
What <apply> have done the trick (with parallel="true")?



MNewcomb@tacintel.com wrote:
> Added support for nested FileSets inside of command line arguments.
> 
> I added this because I could (for the life of me) figure out how to pass
> 'fileset' type results to another executable...  This patch makes it pretty
> intuitive, for me anyway.
> 
> Thanks,
> Michael
> 
> 
> Example:
> 
> <!-- Link the object files.  -->
> <exec executable="${linker}" failonerror="true">
>   <arg line="${linker.options}"/>
>   <arg line="${linker.output}"/>
>   <arg>
>     <fileset dir="${build.src}" includes="*.o"/>
>   </arg>
> </exec>
> 
> 
> ------------------------------------------------------------------------
> 
> Index: Commandline.java
> ===================================================================
> RCS file: /home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/types/Commandline.java,v
> retrieving revision 1.24
> diff -u -r1.24 Commandline.java
> --- Commandline.java	9 Aug 2002 08:49:45 -0000	1.24
> +++ Commandline.java	20 Aug 2002 19:23:28 -0000
> @@ -58,6 +58,8 @@
>  import java.util.StringTokenizer;
>  import java.util.Vector;
>  import org.apache.tools.ant.BuildException;
> +import org.apache.tools.ant.DirectoryScanner;
> +import org.apache.tools.ant.types.FileSet;
>  import org.apache.tools.ant.util.StringUtils;
>  
>  
> @@ -82,6 +84,7 @@
>   *
>   * @author thomas.haas@softwired-inc.com
>   * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
> + * @author <a href="mailto:mnewcomb@tacintel.com">Michael Newcomb</a>
>   */
>  public class Commandline implements Cloneable {
>  
> @@ -116,6 +119,7 @@
>      public static class Argument {
>  
>          private String[] parts;
> +        private Vector fileSets = new Vector();
>  
>          /**
>           * Sets a single commandline argument.
> @@ -163,7 +167,31 @@
>           * Returns the parts this Argument consists of.
>           */
>          public String[] getParts() {
> +            if (parts == null && !fileSets.isEmpty()) {
> +                Vector fullFilenames = new Vector();
> +                for (int i = 0; i < fileSets.size(); i++) {
> +                    FileSet set = (FileSet) fileSets.elementAt(i);
> +
> +                    DirectoryScanner ds =
> +                      set.getDirectoryScanner(set.getProject());
> +                    String filenames[] = ds.getIncludedFiles();
> +                    for (int j = 0; j < filenames.length; j++) {
> +                        File f = new File(ds.getBasedir(), filenames[j]);
> +                        fullFilenames.addElement(f.getAbsolutePath());
> +                    }
> +                }
> +
> +                parts = new String[fullFilenames.size()];
> +                fullFilenames.copyInto(parts);
> +            }
>              return parts;
> +        }
> +
> +        /**
> +         * Adds a set of files.
> +         */
> +        public void addFileset(FileSet set) {
> +            fileSets.addElement(set);
>          }
>      }
>  
> 
> 
> 
> ------------------------------------------------------------------------
> 
> --
> To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>



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