Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ant: How to echo the name of targetfile within apply

Tags:

echo

apply

task

ant

I'm not really familiar with Ant and i wonder how to print the name of the current processed file to the commandline.

This is what i have so far... It's a part of a macro which minifys files with the yui-compressor.

<apply executable="java" parallel="false" verbose="true" dest="@{target}">

    <fileset dir="@{src}">
        <include name="**/*.@{filetype}"/>
    </fileset>

    <arg line="-jar" />
    <arg path="${yui.jar}" />
    <arg value="--charset" />
    <arg value="ANSI" />
    <arg value="-o" />
    <targetfile />

    <mapper type="glob" from="*.@{filetype}" to="*.min.@{filetype}" />
</apply>

What i'm trying to get:

 [echo] Start!
[apply] Processed: filename-1.min.js
[apply] Processed: filename-2.min.js
[apply] Processed: filename-3.min.js
 [echo] Success!
like image 650
gearsdigital Avatar asked Sep 28 '11 21:09

gearsdigital


1 Answers

I don't have a lot of experience with apply but you could try defining your fileset out of the apply element , getting your printed results and then referring to it into your apply element.

<fileset dir="@{src}" id="my.files">
    <include name="**/*.@{filetype}"/>
</fileset>
<pathconvert pathsep="${line.separator}" property="processed.files" refid="my.files"/>
<echo>Start!</echo>
<echo message="${processed.files}"/>

<apply executable="java" parallel="false" verbose="true" dest="@{target}">
    <fileset refid="my.files"/>
    <arg line="-jar" />
    <arg path="${yui.jar}" />
    <arg value="--charset" />
    <arg value="ANSI" />
    <arg value="-o" />
    <targetfile />

    <mapper type="glob" from="*.@{filetype}" to="*.min.@{filetype}" />
</apply>

<echo>Success!</echo>

Of course this will only work if the apply executable doesn't print anything to clutter the output.

like image 172
FailedDev Avatar answered Nov 19 '22 08:11

FailedDev