J
Jari Kujansuu
Hi!
First of all I am using Ant version 1.6.2 (both Windows and Linux).
I am trying to execute java application as a part of the ant build.
This java application should receive couple of files as command-line
parameters. These files might vary and I would like to make a generic
ant task using wildcard characters so that I don't need to start
maintaining build.xml file every time when new file is taken into use.
What I would like to achieve is an ant task that would do corresponding
thing as following command-line example
java -cp . MyJavaApp *.xml
So here is the ant task I made
<target name="runMyJavaApp">
<java classname="MyJavaApp">
<classpath>
<pathelement location="."/>
</classpath>
<arg value="*.xml" />
</java>
</target>
The problem is wildcard character expansion. Above example does not
expand wildcard character * used in arg element and thus MyJavaApp
gets literally *.xml as command-line parameter when it should really
get something like a.xml b.xml c.xml ...
Then I accidentally notice that if I used fork="yes" attribute in java
task then wildcard expansion works in Windows but not in Linux. Like
this
<java classname="MyJavaApp" fork="yes">
...
</java>
I need to run ant build both in Linux and Windows so above solution is
not acceptable.
So has anyone else encoutered same kind of problem earlier and
especially found a solution to it? I would expect that using wildcard
characters would be so common situation that there must be a way to do
it correctly. Or is there some reason why this is not possible in Ant?
Wildcard characters can be used in other places for example in classpath
when building java code. So why it does not work in command-line
arguments?
--
Jari Kujansuu
Nokia Networks
P.O. Box 785, 33101 Tampere, Finland
Hatanpään valtatie 30 / C379.2, 3. floor
E-mail: (e-mail address removed)
Phone: work: +358 (0)7180 74154 mobile: +358 50 4868 538
First of all I am using Ant version 1.6.2 (both Windows and Linux).
I am trying to execute java application as a part of the ant build.
This java application should receive couple of files as command-line
parameters. These files might vary and I would like to make a generic
ant task using wildcard characters so that I don't need to start
maintaining build.xml file every time when new file is taken into use.
What I would like to achieve is an ant task that would do corresponding
thing as following command-line example
java -cp . MyJavaApp *.xml
So here is the ant task I made
<target name="runMyJavaApp">
<java classname="MyJavaApp">
<classpath>
<pathelement location="."/>
</classpath>
<arg value="*.xml" />
</java>
</target>
The problem is wildcard character expansion. Above example does not
expand wildcard character * used in arg element and thus MyJavaApp
gets literally *.xml as command-line parameter when it should really
get something like a.xml b.xml c.xml ...
Then I accidentally notice that if I used fork="yes" attribute in java
task then wildcard expansion works in Windows but not in Linux. Like
this
<java classname="MyJavaApp" fork="yes">
...
</java>
I need to run ant build both in Linux and Windows so above solution is
not acceptable.
So has anyone else encoutered same kind of problem earlier and
especially found a solution to it? I would expect that using wildcard
characters would be so common situation that there must be a way to do
it correctly. Or is there some reason why this is not possible in Ant?
Wildcard characters can be used in other places for example in classpath
when building java code. So why it does not work in command-line
arguments?
--
Jari Kujansuu
Nokia Networks
P.O. Box 785, 33101 Tampere, Finland
Hatanpään valtatie 30 / C379.2, 3. floor
E-mail: (e-mail address removed)
Phone: work: +358 (0)7180 74154 mobile: +358 50 4868 538