You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Aaron Alpar <aa...@webgain.com> on 2000/11/16 18:42:14 UTC

Neophite Questions ...

Hi All,
	I'm a long time make user that's looking for an alternative for my Java 
and C development work.  I've been looking at Ant recently - so far it 
looks promising, but I have some questions:
How do you do wildcard dependencies?
		In make you can have suffix rules and rules that are based on 
wildcards, for example a (.class.java) rule will tell make how to turn 
.java files into .class files (this is not as necessary with javac as it 
is with cc).  Does Ant allow for this?  Does it allow for wildcatted 
rules like the %.class: s.%.java rules in make do?  If so how do you do 
this or where is it documented??  I couldn't find anything in the ant 
docs on wildcards.  
How do you get file lists in Ant like you do in make??
		For example, in make you can get a list out-of-date files in the 
dependency by using $? and the target by specifing $@ (did i get that 
right?).  Can you get similar lists in Ant and pass those onto a shell 
script or a Java program?  If so, are there some examples that I can look at?
	One more bit: make allows you to say "There should be a *.class file for 
each .java file in this directory" (a little different than a suffix 
rule) by specification of something like (${@}*.class):(${?}*java) - 
don't quote me on the syntax, I don't have my make manuals in front of 
me, but it kinda looks like that. 
	Anyhow, how's this kinda stuff get done in Ant??  I would like to know!  
Any help is appreciated.
	Aaron Alpar
	WebGain
	aaron.alpar@webgain.com

Re: Neophite Questions ...

Posted by Stefan Bodewig <bo...@apache.org>.
Peter Donald <do...@apache.org> wrote:

> yep but that is not wildcard matching. That Is a specific task
> matching a specific pattern in a specific directory ;)

Let's not start splitting hairs. What it will look like is something
close to

<transform executable="gcc" targetdir="build/C">
  <arg value="-c" />
  <srcfile />
  <arg value="-o" />
  <targetfile />

  <fileset dir="src/C" />
  <mapper type="glob" from="*.c" to="*.o" />
</transform>

which is quite general and does wildcard matching, IMHO. It can be
used for other things as well, like

<transform executable="jade" targetdir="doc/docbook">
  <arg line="-t rtf -d mystylesheet.dsl" />
  <srcfile />

  <fileset dir="doc/docbook" />
  <mapper type="glob" from="*.sgml" to="*.rtf" />
</transform>

and there might even be a mapper type="regexp" ...

Stefan

Re: Neophite Questions ...

Posted by Peter Donald <do...@apache.org>.
At 09:08  17/11/00 +0100, you wrote:
>Peter Donald <do...@apache.org> wrote:
>
>>>How do you do wildcard dependencies?
>> 
>> you can't and will never be able to.
>
>Don't think so Pete (the never be able part). I think we will have a
>task in Ant 1.3 that will do things like invoke 
>
>gcc -c source -o target
>
>for each source that matches *.c in a directory tree which is newer
>than the corresponding target *.o. Just let me get my act together 8-).

yep but that is not wildcard matching. That Is a specific task matching a
specific pattern in a specific directory ;) 


Cheers,

Pete

*------------------------------------------------------*
| Despite your efforts to be a romantic hero, you will |
| gradually evolve into a postmodern plot device.      |
*------------------------------------------------------*


Re: Neophite Questions ...

Posted by Stefan Bodewig <bo...@apache.org>.
Peter Donald <do...@apache.org> wrote:

>>How do you do wildcard dependencies?
> 
> you can't and will never be able to.

Don't think so Pete (the never be able part). I think we will have a
task in Ant 1.3 that will do things like invoke 

gcc -c source -o target

for each source that matches *.c in a directory tree which is newer
than the corresponding target *.o. Just let me get my act together 8-).

Stefan

Re: Neophite Questions ...

Posted by Peter Donald <do...@apache.org>.
> I'm a long time make user that's looking for an alternative for my Java
and C >development work. I've been looking at Ant recently - so far it
looks >promising, but I have some questions:

kewl ;)
  
>How do you do wildcard dependencies?

you can't and will never be able to. These type of constructs are
considered too complex and in Ant all complexity goes into tasks. So
instead of going 

%.class: %.java
	javac $@ 

(or whatever syntax is - long time ince my last use of make ;])

you would go 
   <javac srcdir="." destdir="."/>

and the task would handle all the complexities. You could also do the
following that is equivelent

   <javac srcdir="." destdir=".">
       <include name="**/*.java" />
   </javac>
  
>How do you get file lists in Ant like you do in make??
you may be able to (not sure - I seem to remember someone commenting on the
functionality) but it really is completely unrecommended. Use
patternsets/filesets etc which are documented in ant docs.
  
> One more bit: make allows you to say "There should be a *.class file for
each >.java file in this directory" (a little different than a suffix rule)
by >specification of something like (${@}*.class):(${?}*java) - don't quote
me on >the syntax, I don't have my make manuals in front of me, but it
kinda looks >like that.  

You can't unless you write your own task to do that ;)

Cheers,

Pete

*------------------------------------------------------*
| Despite your efforts to be a romantic hero, you will |
| gradually evolve into a postmodern plot device.      |
*------------------------------------------------------*