ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Bailey" <ch...@codeintensity.com>
Subject RE: Accessing the individual files in the file list
Date Wed, 29 May 2002 20:07:12 GMT
I'm converting a makefile, and we have lots of our own compilers that seem
to do almost exactly the same thing as you describe (ours turn XML into Java
source).  Our original command lines for this also had us passing the
package name as a param.  But, I couldn't see an easy (or any?) way to do
this easily in Ant, so I modified our compilers, to what I think is actually
a better way.  I now just pass a filename to the compiler.  It turns that
into an absolute File/path (i.e. in case it was passed as a relative path).
I then just rip off the filename, and I'm left with the package name.
Depending on your directory structure and so on, this may or may not be
feasible for you, but that's what I wound up doing.

I'm hoping to eventually just turn our compilers into Ant tasks, but due to
a few other factors, I can't do that nicely yet.

-----Original Message-----
From: John Mc Quillan [mailto:john.mcquillan@openjawtech.com]
Sent: Wednesday, May 29, 2002 12:23 PM
To: ant-user@jakarta.apache.org
Subject: Accessing the individual files in the file list


Is there a way in Ant to get at the individual files in the file list (the
equivalent of $< or $@ in make)?

I'll try to explain with the following snippet. This is generating java
source from xml schema files. A command line parameter allows the package
name for output to be defined. What I'd like to do is set the package name
to the name of the input file. Can I do this with a script? How would I get
the file name in a script?

I tried using <source/> but I need it for the input filename and it cannot
be used multiple times.

<target name="sourcegen" depends="init">
	<apply executable="java" dest="${gensrc}">
		<arg line="org.exolab.castor.builder.SourceGenerator -f -package
test -dest ${src} -i"/>
		<mapper type="glob" from="*.xsd" to="*.java"/>
		<fileset dir="${schema}"/>
	</apply>
</target>

Thanks

John


--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>



--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message