|
|
07.02.2004 |
|
||||||||||
| Ant's Apply Task | ||||||||||||
I've been a computer geek since a boy, and thoughts related to computers and software engineering get dropped here for the benefit of humanity and my own hubris.
|
I wanted to have an Ant task that took some files and ran them through a Perl script as a filter. Seems like a job for the Let me first show you the section from my <apply dest="${dist}" executable="perl" parallel="false">
<arg file="${src.support}/Markdown.pl" />
<fileset dir="${src.docs}">
<include name="**/*.txt"/>
</fileset>
<mapper type="glob" from="*.txt" to="*.htm" />
</apply>
Seems fairly simple enough… In the But therein lies the problem You would think that the But what should the value of this After spending a great deal of time in Google looking for the answer, it appears that no one thought about an executable that acted like this. All of the examples that I could find assume that the executable can take something like a “-o” option for specifying the output file. If my script could handle something like that, then I would, instead, write the following: <apply dest="${dist}" executable="perl" parallel="false">
<arg file="${src.support}/Markdown.pl" />
<arg value="-o" />
<targetfile />
<fileset dir="${src.docs}">
<include name="**/*.txt"/>
</fileset>
<mapper type="glob" from="*.txt" to="*.htm" />
</apply>
The thinking here is that each original file is given to the script that looks like this: perl support/Markdown.pl -o file1.htm <sigh> It took me longer to hunt through Google looking for an answer than it took for me to hack the perl script to add an “-o” option to it. But I still want to know the answer, so if you, gentle reader, know the answer, please let me know. And if you want to know the answer, keep checking back to this page, for when I find it, I’m gonna post it. Thought originally posted on Friday, 2 July 2004
© 2004-2005, Howard Abrams • Except where otherwise noted, all original content is licensed under a Creative Commons License (see details). A comment to this from jw
I do believe, as of Ant 1.6.2, the I/O redirector will solve the problem for you. See the ant manual (http://ant.apache.org/manual/index.html) and the Apply/ExecOn task Towards the bottom, I/O redirectors are discussed. To quote the page: “This grants the user the capacity to receive input from, and send output to, different files for each sourcefile see the example at the very very bottom (the fictitious “processfile” command) Comment posted on Sunday, 14 November 2004 |
|||||||||||
|
||||||||||||