Ant: how to display the name of the target file in the application

I am not very familiar with Ant, and I am wondering how to print the name of the current processed file on the command line.

This is what I have so far ... This is part of a macro that minifys files with a 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 am I 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! 
+6
source share
2 answers

I do not have much experience with the application, but you can try to determine your set of files from the element used, get your printed results and then refer to it in your application 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 application executable does not print anything to clutter up the output.

+2
source

The best way I've found this is to add the debug or verbose flag to ant:

ant target-name -debug or ant target-name -verbose

Then the executable line will be printed. For instance:

 [apply] Executing 'lib\NUnit\bin\nunit-console-x86.exe' with arguments: [apply] '/noshadow' [apply] '/domain:multiple' [apply] '/labels' [apply] '/framework:net-4.5' [apply] '/nologo' [apply] 'C:\blah\foo.Tests.dll 

Unfortunately, this will detail everything, not just the specific apply .

0
source

Source: https://habr.com/ru/post/898243/


All Articles