views:

664

answers:

3

I'm new to ant. I'm looking to a way to do this

I have a folder, with a variable number of subfolders. Suppose subfolders are s1,s2,s3...,sN (N is not known)

I need to create and execute this command line

java -jar myjar.jar s1\ s2\ s3\ ... sN\

I would like to use standard task, but I do not know how to list folders on the command line.

Any help would really be appreciated!

Alberto

+1  A: 

I think fileset task is what you're looking for:

http://ant.apache.org/manual/CoreTypes/fileset.html

The jar task can work with implicit filesets, or you can define custom filesets within the jar task.

http://ant.apache.org/manual/CoreTasks/jar.html

See the examples at the bottom of the jar page.

Andy White
A: 

I think that the jar task is NOT what I need. I have to execute an existing jar, not to create a new jar.

I know fileset and dirset (which I'm using).

What I was able to achieve is this

<pathconvert pathsep="\&quot; &quot;" property="folders_temp">
 <dirset dir="junitHistory">
      <include name="junit*"/> 
 </dirset>
    </pathconvert>
<property name="folders" value="&quot;${folders_temp}\&quot;"/>

<java dir="junitHistory" jar= "./unitth.jar" fork="true" output="ant.log">
  <arg value="${folders}"/>      
</java>

With these, jar is executed, but the problem is that all folders s1...SN are passed with the full path (ie c:\aaa\bbb\ccc\s1\, c:\aaaa\bbb\ccc\s2, etc) and for some reason this does not work for the jar (the jar is an external library that we cannot modify).

So, what I have to do is find a way to list folders without absolute path. Maybe there is some parameters in the pathconvert task, or I need to use a different task to create a property with the list of folders ?

thank you Alberto

Hi Alberto, This additional info is best put in your question by clicking "edit" above on your question and putting it there. Afterward, delete this answer. You are more likely to get higher quality answers by having all of the information listed in your question.
Alex B
A: 

You cac create an ant custom task which get the parent dir, a dirset or a patternset and writes all the names into an ant property

See more about it here http://ant.apache.org/manual/develop.html

David Rabinowitz