Converting an Ant fileset to multiple apply args

后端 未结 1 863
囚心锁ツ
囚心锁ツ 2020-12-31 04:18

I have some files:

dir/foo.txt
dir/bar.txt
dir/foobar.txt

In an Ant apply task, I want to pass the list of files as arguments:

相关标签:
1条回答
  • 2020-12-31 04:35

    Here's an example illustrating the use of the pathconvert task.

    The converted path is passed to the executable using <arg line />.

    This assumes no spaces in the paths of your *.txt files.

    <target name="atask">
        <fileset dir="dir" id="myTxts">
            <include name="*.txt" />
        </fileset>
        <pathconvert property="cmdTxts" refid="myTxts" pathsep=" " />
    
        <apply executable="${cmd}" parallel="false" verbose="true">
            <arg value="-in" />
            <srcfile />
            <arg line="${cmdTxts}" />
    
            <fileset dir="${list.dir}" includes="*.list" />
        </apply>
    </target>
    

    If you might encounter spaces this should do: as above, but change (hopefully obvious which lines) to:

        <pathconvert property="cmdTxts" refid="myTxts" pathsep="' '" />
    

    and

            <arg line="'${cmdTxts}'"/>
    
    0 讨论(0)
提交回复
热议问题