ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <>
Subject AW: apply task trouble for command using < and >
Date Fri, 25 Nov 2005 12:05:58 GMT
I tuned the example...

	<!-- Define a new 'task' for easier use -->
	<macrodef name="jsmin">
		<!-- Where to find the development version of JavaScript files -->
		<attribute name="srcDir"/>
		<!-- Where to store the 'compressed' files -->
		<attribute name="destDir"/>
		    <!-- Iterate over the JS-files and dont pass the filename as argument -->
            <apply executable="jsmin" addsourcefile="false">
            	<!-- Collect the JS-files -->
                <fileset dir="@{srcDir}" includes="*.js"/>
                    <!-- redirect STDIN; fileset collects relative to its dir, but we need
relative to basedir -->
                    <inputmapper type="glob" from="*" to="@{srcDir}/*"/>
                    <!-- redirect STDOUT to file in dest-dir -->
		            <outputmapper id="out" type="glob"

	<target name="jsmin2">
		<!-- compress the JavaScript files -->
		<jsmin srcDir="src" destDir="dest"/>
		<!-- print the compressed files out - for check only -->
        <concat><fileset dir="dest"/></concat>


>-----Urspr√ľngliche Nachricht-----
>Von: Jakob Fix [] 
>>         <mapper id="out" type="glob"
>>                 from="*.js"
>>                 to="dest/*.js"/>
>"Map" (whatever this means exactly) each file ending in .js to 
>dest/*.js.  This will be used later on.

Mapping means applying a rule for converting a amount of names to
other names. You could think about using a 
but you got the meaning.

>>         <apply executable="jsmin">
>>             <fileset dir="src" includes="*.js"/>
>Create a fileset of all files in the src/ directory ending in 
>.js.  I guess this is represented internally as a list of 
>absolute pathnames of all files ending .js in the src/ 
>directory.  The apply task will then cycle through this list, 
>file by file.

Nope - not the fileset itself gives you absolute filenames. The
DirectoryScanner used internally does that. Have a look at the 
Tutorial "Tasks using Properties, Filesets & Paths" in the manual
for more about using filesets in tasks.

>>             <mapper refid="out"/>
> At least, I found you can put this element anywhere inside 
>the apply task.  Another thing, I commented this line out, and 
>the results are the same.  Bizarre?!

Havent looked at that. But maybe <apply> ignores nested <mappers> silently -
maybe only if a <redirector> is present. Main point here is the definition with
"id" and reusing it via "refid".

>And it works!  Wow, that's what I call black magic.

Black magic is ok ... for the first (few) steps.
But we want to give more knowledge to convert that into "white magic" ;-)

>Although, there's still one minor hiccup; the input filename 
>is passed to jsmin as an argument, but where?  I know this 
>because it re-appears at the beginning of the out output file 
>as a comment, which is what jsmin does with additional 
>arguments.  (This is why I tried to uncomment the <mapper 
>refid="out"/> line, but to no effect.)

Standard behaviour of <apply>, but can be switched off - as done in the
new code.

>Thanks a lot.  Now, how can I contribute some documentation for this?

For what exactly? 
Contributions are welcome as patches in bugzilla.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message