ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@apache.org>
Subject Re: How to tell a task to fail if the fileset includes are missing?
Date Tue, 28 Oct 2003 10:26:56 GMT
On Fri, 24 Oct 2003, Matt Harp <mharp@seapine.com> wrote:

> How can I tell the build.xml to fail if one of those files is not
> found?

The canonical way would be

<condition property="both.files.present">
  <and>
    <available file="${src}/plugin.xml"/>
    <available file="${src}/plugin.properties"/>
  </and>
</condition>
<fail unless="both.files.present>
One of the required files is missing.
</fail>

As an alternative you can use <zip> instead of <jar>

     <zip destfile="${dist}/${jarfilename}" compress="true"
          encoding="UTF8" whenempty="fail">
        <fileset dir="${src}" includes="plugin.xml" />
        <fileset dir="${src}" includes="plugin.properties" />
     </zip>

and run an additional <jar> after that if you need a manifest and want
to use Ant's default manifest.

Note that the <zip> version will only fail if neither file is there
while the first version (using <fail>) will fail if one of the two
files is missing.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message