1

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?

yegor256
  • 102,010
  • 123
  • 446
  • 597

1 Answers1

3

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>
martin clayton
  • 76,436
  • 32
  • 213
  • 198