Ant concat task complains about missing files

<concat destfile="dist/external.js">
  <fileset dir=".">
    <include name="a.js" />
    <include name="b.js" />
  </fileset>
</concat>

This will not work if missing or. I tried setting optional = "false" or asis = "true" and he always complains that these attributes do not exist.

+3
source share
1 answer

If you just want to see a warning from the "concat" task when the file is missing, you can use resource collection instead of the "file set":filelist

<concat destfile="dist/external.js">
  <filelist dir=".">
    <file name="a.js" />
    <file name="b.js" />
  </filelist>
</concat>

If it b.jsdoes not exist, this gives a message:

[concat] /Path/.../b.js does not exist.

But still, that is probably not what you want.

. : antlib: org.apache.tools.ant.types.resources.selectors, . ( Ant 1.7.0.) Ant fail, , .

<project name="stack_overflow"
         xmlns:rsel="antlib:org.apache.tools.ant.types.resources.selectors">

<filelist id="my.js.files" dir=".">
    <file name="a.js" />
    <file name="b.js" />
</filelist>

<restrict id="missing.js.files">
  <filelist refid="my.js.files"/>
  <rsel:not>
    <rsel:exists/>
  </rsel:not>
</restrict>

<property name="missing.files" refid="missing.js.files" />
<fail message="These files are missing: ${missing.files}">
  <condition>
    <length string="${missing.files}" when="greater" length="0" />
  </condition>
</fail>
<concat destfile="dist/external.js">
    <filelist refid="my.js.files" />
</concat>

</project>

, , b.js , "concat" :

BUILD FAILED
/Path/.../build.xml:17: These files are missing: /Path/.../b.js
+2

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


All Articles