开发者

How to pass a list of files to <exec>?

This is a part of my ant script:

<target>
  <exec executable="find" outputproperty="found">
    <arg value="src/main/java"/>
    <arg line="-name '*.java'"/>
  </exec>
  <exec executable="xgettext">
    <arg value="-k_"/>
    <arg line="-o gettext.pot"/>
    <arg line="${found}"/>
  </exec>
</target>

Doesn't work because xgettext receives a quoted list of files and treats this list as a single file name. How to solve开发者_开发问答 it?


You'd need to separate out each file to a separate arg for that to work.

You can supply a list-of-files file to process to 'xgettext' using the --files-from option. How about something like this: write the 'find' output to a file, then reload into 'xgettext':

<target>
  <exec executable="find" outputproperty="found">
    <arg value="src/main/java"/>
    <arg line="-name '*.java'"/>
  </exec>
  <echo file="xgettext.files" message="${found}" />
  <exec executable="xgettext">
    <arg value="-k_"/>
    <arg value="-o" />
    <arg value="gettext.pot"/>
    <arg value="--files-from=xgettext.files"/>
  </exec>
</target>

Alternatively, here's a variation that assumes you have the Bourne Shell sh - if you have something else you can probably adapt. This pipes the 'find' output directly to 'xgettext':

<exec executable="sh">
    <arg value="-c"/>
    <arg value="find src/main/java -name '*.java' | xgettext -k_ -o gettext.pot -f -"/>
</exec>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜