Ant:如何在apply中回显targetfile的名称
我对Ant不是很熟悉,我想知道如何将当前处理文件的名称打印到命令行 这就是我目前所拥有的。。。这是宏的一部分,它使用yui压缩器缩小文件Ant:如何在apply中回显targetfile的名称,ant,echo,task,apply,Ant,Echo,Task,Apply,我对Ant不是很熟悉,我想知道如何将当前处理文件的名称打印到命令行 这就是我目前所拥有的。。。这是宏的一部分,它使用yui压缩器缩小文件 <apply executable="java" parallel="false" verbose="true" dest="@{target}"> <fileset dir="@{src}"> <include name="**/*.@{filetype}"/> </fileset&
<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>
我对apply没有太多经验,但您可以尝试从apply元素中定义文件集,获得打印结果,然后将其引用到apply元素中
<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>
开始
成功!
当然,这只有在应用可执行文件不打印任何内容以使输出混乱的情况下才起作用。我发现最好的方法是将debug或verbose标志添加到ant:
ant目标名称-调试
或ant目标名称-详细
然后将打印正在执行的命令行。例如:
[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
不幸的是,这将详细记录所有内容,而不仅仅是特定的apply
注意:这将在开始apply之前打印所有文件名,而不是OP想要的“当前处理的文件”。
[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