AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problem with Ant: Wildcard character expansion in command-li

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Software Tools
View previous topic :: View next topic  
Author Message
Jari Kujansuu
Guest





PostPosted: Thu Jun 02, 2005 7:38 am    Post subject: Problem with Ant: Wildcard character expansion in command-li Reply with quote




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: [email]jari.kujansuu (AT) nokia (DOT) com[/email]
Phone: work: +358 (0)7180 74154 mobile: +358 50 4868 538
Back to top
Juha Laiho
Guest





PostPosted: Thu Jun 02, 2005 8:11 pm    Post subject: Re: Problem with Ant: Wildcard character expansion in comman Reply with quote



Jari Kujansuu <jari.kujansuu (AT) nokia (DOT) com> said:
Quote:
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.
....
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.

I'll hazard a guess as to why this is so. No solutions, though, but
perhaps this helps in finding one.

In Windows (or DOS, for that matter), expanding wildcard filename arguments
has been the task of the application receiving the arguments. So, each
application has contained code to handle wildcards in arguments.

In Unix (and like) systems, wildcard expansion has been a task for the
shell interpreting the commands.

When you start a task with 'fork="yes"' in ant, it'll just start the
requested task, but not a separate shell. Thus, in Windows, the
started task (process) will handle the wildcard expansion, but in
Linux, as shell is not started, there's nothing to expand the
wildcards.
--
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)

Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Software Tools All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.