You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Stefan Kost <s....@webmacher.de> on 2002/04/30 11:39:01 UTC
outputting a fileset as xml
Hi,
I've search the web, the mailing lists and even asked friends - but no
answer has been found.
I need a fileset as xml :
<files>
<file>path-to-file-1</file>
<file>path-to-file-2</file>
<file>path-to-file-3</file>
...
</files>
to further process this with the styler (I am trying to build my EJB
deployment descriptor from fragments).
I currently tried the follwoing code :
<delete file="${basePath}/xmlfiles.xml"/>
<echo file="${basePath}/xmlfiles.xml"><files>
</echo>
<exec dir="${basePath}"
executable="find" output="${basePath}/xmlfiles.xml">
<arg line="${sourcePath} -name "ejb-jar.xml" -printf
" <file>%p</file>\n""/>
</exec>
<echo file="${basePath}/xmlfiles.xml" append="yes"></files>
</echo>
This isn't nice as I need to use exec to use the unix-find command.
And it doesn't work as exec has no append option like exec
<hint>feature-request</hint>
Does anyone know about a external task to do it. Otherwise I will check
the docs and write one.
Stefan
--
< W E B M A C H E R >
EDV+INTERNETSERVICE GMBH
POST: August Bebel Str. 69
04275 Leipzig
FON: +49 341 30 34 833
FAX: +49 341 30 34 840
WEB: www.webmacher.de
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: outputting a fileset as xml
Posted by Stefan Bodewig <bo...@apache.org>.
On 30 Apr 2002, Stefan Kost <s....@webmacher.de> wrote:
> And it doesn't work as exec has no append option like exec
like echo, I guess.
> <hint>feature-request</hint>
already inplemented in 1.5alpha 8-)
Can't you use <exec>'s outputproperty to capture find's result in a
property and then <echo> that property to your file? This should work
in 1.4.1.
Stefan
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: outputting a fileset as xml
Posted by Diane Holt <ho...@yahoo.com>.
--- Erik Hatcher <ja...@ehatchersolutions.com> wrote:
> Or write a custom task which would take about the same number of lines
> of code and much more reusable and clearer. :))
I'm not sure I'd agree with that -- I suspect a task would be considerably
more lines (script would be about a dozen lines), a <script> task should
be just as reusable, and I don't see <script>'s as being any less clear,
maybe even more so, since you don't need to know as much about Ant's
internals to read through one and get a pretty good idea of what it's
doing.
Diane
=====
(holtdl@yahoo.com)
__________________________________________________
Do You Yahoo!?
Yahoo! Health - your guide to health and wellness
http://health.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: outputting a fileset as xml
Posted by Erik Hatcher <ja...@ehatchersolutions.com>.
Or write a custom task which would take about the same number of lines of
code and much more reusable and clearer. :))
Erik
----- Original Message -----
From: "Diane Holt" <ho...@yahoo.com>
To: "Ant Users List" <an...@jakarta.apache.org>
Sent: Tuesday, April 30, 2002 5:52 AM
Subject: Re: outputting a fileset as xml
> --- Stefan Kost <s....@webmacher.de> wrote:
> > I've search the web, the mailing lists and even asked friends - but no
> > answer has been found.
> > I need a fileset as xml :
> > <files>
> > <file>path-to-file-1</file>
> > <file>path-to-file-2</file>
> > <file>path-to-file-3</file>
> > ...
> > </files>
>
> Use <fileset> to get the set of files, <pathconvert> it to a list, then
> either use <foreach> to <echo> the text and files out to a file (if you
> can go with Ant1.5[soon to go beta]), or for-loop through them in a
> <script>.
>
> Diane
>
> =====
> (holtdl@yahoo.com)
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Health - your guide to health and wellness
> http://health.yahoo.com
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: outputting a fileset as xml
Posted by Scott Ellsworth <sc...@alodar.com>.
On Tuesday, April 30, 2002, at 03:49 AM, Erik Hatcher wrote:
> Soon - as in this week!
Wonderful - I am very impressed with the work of the people
contributing, and have found ANT a tremendous improvement in my coding
life. I still use IDEs for all of my main work, but these are backed
with ANT scripts to handle the heavy lifting, as then I know ANYONE can
build my code if they have a 1.2 JDK.
Scott
>
> From: "Stefan Kost" <s....@webmacher.de>
> Subject: Re: outputting a fileset as xml
>
>> thanks for all prompt replies. How soon is 'soon' ?
>>> Use <fileset> to get the set of files, <pathconvert> it to a list,
>>> then either use <foreach> to <echo> the text and files out to a file
>>> (if you can go with Ant1.5[soon to go beta]), or for-loop through
>>> them in a <script>.
>>> (holtdl@yahoo.com)
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: outputting a fileset as xml
Posted by Erik Hatcher <ja...@ehatchersolutions.com>.
Soon - as in this week!
----- Original Message -----
From: "Stefan Kost" <s....@webmacher.de>
To: "Ant Users List" <an...@jakarta.apache.org>
Sent: Tuesday, April 30, 2002 6:20 AM
Subject: Re: outputting a fileset as xml
> Hi,
>
> thanks for all prompt replies. How soon is 'soon' ? I've got a task for
> that purpose about 80% ready :-( and now thinking what is better, to
> wait for 1.5 or to finish it.
>
> Stefan
> > --- Stefan Kost <s....@webmacher.de> wrote:
> > > I've search the web, the mailing lists and even asked friends - but no
> > > answer has been found.
> > > I need a fileset as xml :
> > > <files>
> > > <file>path-to-file-1</file>
> > > <file>path-to-file-2</file>
> > > <file>path-to-file-3</file>
> > > ...
> > > </files>
> >
> > Use <fileset> to get the set of files, <pathconvert> it to a list, then
> > either use <foreach> to <echo> the text and files out to a file (if you
> > can go with Ant1.5[soon to go beta]), or for-loop through them in a
> > <script>.
> >
> > Diane
> >
> > =====
> > (holtdl@yahoo.com)
> >
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Yahoo! Health - your guide to health and wellness
> > http://health.yahoo.com
> >
> > --
> > To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> > For additional commands, e-mail:
<ma...@jakarta.apache.org>
> >
> --
>
> < W E B M A C H E R >
> EDV+INTERNETSERVICE GMBH
>
> POST: August Bebel Str. 69
> 04275 Leipzig
>
> FON: +49 341 30 34 833
> FAX: +49 341 30 34 840
> WEB: www.webmacher.de
>
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: outputting a fileset as xml
Posted by Stefan Kost <s....@webmacher.de>.
Hi,
thanks for all prompt replies. How soon is 'soon' ? I've got a task for
that purpose about 80% ready :-( and now thinking what is better, to
wait for 1.5 or to finish it.
Stefan
> --- Stefan Kost <s....@webmacher.de> wrote:
> > I've search the web, the mailing lists and even asked friends - but no
> > answer has been found.
> > I need a fileset as xml :
> > <files>
> > <file>path-to-file-1</file>
> > <file>path-to-file-2</file>
> > <file>path-to-file-3</file>
> > ...
> > </files>
>
> Use <fileset> to get the set of files, <pathconvert> it to a list, then
> either use <foreach> to <echo> the text and files out to a file (if you
> can go with Ant1.5[soon to go beta]), or for-loop through them in a
> <script>.
>
> Diane
>
> =====
> (holtdl@yahoo.com)
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Health - your guide to health and wellness
> http://health.yahoo.com
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
--
< W E B M A C H E R >
EDV+INTERNETSERVICE GMBH
POST: August Bebel Str. 69
04275 Leipzig
FON: +49 341 30 34 833
FAX: +49 341 30 34 840
WEB: www.webmacher.de
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: outputting a fileset as xml
Posted by Diane Holt <ho...@yahoo.com>.
--- Stefan Kost <s....@webmacher.de> wrote:
> I waited for ant-1.5b1 but miss the foreach. At least there is no
> documentation for it. I check the binary-jar to see if the is a class,
> named like this and there ins't one.
> Can you enlighten me on this ?
The <foreach> task is part of the ant-contrib project on Sourceforge:
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/ant-contrib/ant-contrib/src/net/sf/antcontrib/logic
As an example of using it for your case:
<fileset id="xmlfiles" dir="${sourcePath}">
<include name="**/ejb-jar.xml"/>
</fileset>
<target name="xmlfs">
<echo file="${basepath}/xmlfiles.xml"><![CDATA[
<files>]]></echo>
<pathconvert property="xmlfiles" pathsep="," refid="xmlfiles">
<map from="${sourcePath}${file.separator}" to=""/>
</pathconvert>
<foreach list="${xmlfiles}" target="genXmlFS" param="xmlfile"/>
<echo file="${basepath}/xmlfiles.xml" append="true"><![CDATA[
</files>
]]></echo>
</target>
<target name="genXmlFS">
<echo file="${basepath}/xmlfiles.xml" append="true"><![CDATA[
<file>${xmlfile}</file>]]></echo>
</target>
And just for completeness, since I also mentioned doing it with <script>:
<target name="xmlfs">
<delete file="xmlfiles.xml"/>
<pathconvert property="xmlfiles" pathsep="," refid="xmlfiles">
<map from="${sourcePath}${file.separator}" to=""/>
</pathconvert>
<script language="javascript"> <![CDATA[
importClass(java.io.File);
importClass(java.io.FileWriter);
importClass(java.util.StringTokenizer);
outfile = new File("xmlfiles.xml");
var append = true;
var lsep = project.getProperty("line.separator");
out = new FileWriter(outfile, append);
files = project.getProperty("xmlfiles");
out.write("<files>" + lsep);
st = new StringTokenizer(files, " ,");
while (st.hasMoreTokens()) {
file = st.nextToken();
out.write(" <file>" + file + "</file>" + lsep);
}
out.write("</files>" + lsep);
out.close();
]]> </script>
</target>
Diane
=====
(holtdl@yahoo.com)
__________________________________________________
Do You Yahoo!?
Yahoo! Health - your guide to health and wellness
http://health.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: outputting a fileset as xml
Posted by Stefan Kost <s....@webmacher.de>.
Hi Diane,
> --- Stefan Kost <s....@webmacher.de> wrote:
> > I've search the web, the mailing lists and even asked friends - but no
> > answer has been found.
> > I need a fileset as xml :
> > <files>
> > <file>path-to-file-1</file>
> > <file>path-to-file-2</file>
> > <file>path-to-file-3</file>
> > ...
> > </files>
>
> Use <fileset> to get the set of files, <pathconvert> it to a list, then
> either use <foreach> to <echo> the text and files out to a file (if you
> can go with Ant1.5[soon to go beta]), or for-loop through them in a
> <script>.
I waited for ant-1.5b1 but miss the foreach. At least there is no
documentation for it. I check the binary-jar to see if the is a class,
named like this and there ins't one.
Can you enlighten me on this ?
Stefan
--
< W E B M A C H E R >
EDV+INTERNETSERVICE GMBH
POST: August Bebel Str. 69
04275 Leipzig
FON: +49 341 30 34 833
FAX: +49 341 30 34 840
WEB: www.webmacher.de
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: outputting a fileset as xml
Posted by Diane Holt <ho...@yahoo.com>.
--- Stefan Kost <s....@webmacher.de> wrote:
> I've search the web, the mailing lists and even asked friends - but no
> answer has been found.
> I need a fileset as xml :
> <files>
> <file>path-to-file-1</file>
> <file>path-to-file-2</file>
> <file>path-to-file-3</file>
> ...
> </files>
Use <fileset> to get the set of files, <pathconvert> it to a list, then
either use <foreach> to <echo> the text and files out to a file (if you
can go with Ant1.5[soon to go beta]), or for-loop through them in a
<script>.
Diane
=====
(holtdl@yahoo.com)
__________________________________________________
Do You Yahoo!?
Yahoo! Health - your guide to health and wellness
http://health.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>