You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Mike Deibler <md...@nocpulse.com> on 2000/07/31 17:22:44 UTC

Creating a list of files for a task

Hello,

I have a build target that runs java on a class file.  One of the
parameters to the class file is a listing of certain files in a
directory structure.  For example:

java Maker dir1/file.in dir1/file2.in dir2/file3.in dirN/fileM.in


I'm trying to use the java task to do this with a predefined 
property that uses the ** file matching criteria.  For example:

<!-- simplified -->
<target name="init">
  <property name="include_files" value="**/*.in" />       
  <property name="classpath" value="listing of classpath" />
</target>

<target name="build" depends="init">
  <java classname="Maker"
        args="${include_files}"
        fork="yes"
        jvmargs="-classpath ${classpath}"
  />
</target> 


The problem with this approach is that the **/*.in isn't converted
into a file list when the java command is run.  It generates something
like:

java Maker **/*.in


Is there any way to generate a list of files that can be used in the
java task above?  Or will I have to write something that will do something
similar to a unix 'find' command and pass the results into the java
task?

I'm using ant version 1.0.8.


Thanks,

Mike

-- 
Mike Deibler

NocPulse, Inc.
1293 Mountain View-Alviso Road, Suite D
Sunnyvale, CA  94089

Re: Creating a list of files for a task

Posted by Stefan Bodewig <bo...@bost.de>.
>>>>> "MD" == Mike Deibler <md...@nocpulse.com> writes:

 MD> Hello, I have a build target that runs java on a class file.  One
 MD> of the parameters to the class file is a listing of certain files
 MD> in a directory structure.  For example:

 MD> java Maker dir1/file.in dir1/file2.in dir2/file3.in dirN/fileM.in


You can't do this in Ant 1.1 but the next version of Ant will have a
functionality like this. Using current CVS and the undocumented execon
task this will look like

<execon executable="java" parallel="yes">
  <arg value="-classpath" />
  <arg value="${classpath}" />
  <arg value="Maker" />
  <fileset dir="dir1">
    <patternset id=".in">
      <include name="**/*.in">
    </patternset>
  </fileset>
  <fileset dir="dir2">
    <patternsetref refid=".in" />
  </fileset>
  ...
</execon>

which could be shortened to a single fileset if you don't need
different patterns for the different directories and all dirs share a
common root.

I'm just throwing out a couple of new concepts without explaining
them, I know. I hope you can grasp the idea from the snippet above -
the syntax may change before we get to a release though.

Stefan