You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Kamal Bhatt <kb...@tt.com.au> on 2005/12/20 02:23:14 UTC

jar and isempty

Hi
I am creating a jar file and I would like the script to fail if the jar 
file is not going to be composed of any significant files (I do not view 
the manifest files as significant in this case)

I used whenempty="fail" and instead of failure I get a stupid message 
telling me that a jar file is never empty (because of the manifest 
file). Is there a way of making it work the way I expect it to work (ie 
failing when there are no files in the file set) instead of this rather 
unhelpful way?

Thanks.

Kamal.

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


Re: jar and isempty

Posted by Stefan Bodewig <bo...@apache.org>.
On Tue, 20 Dec 2005, Kamal Bhatt <kb...@tt.com.au> wrote:

> I used whenempty="fail" and instead of failure I get a stupid
> message telling me that a jar file is never empty (because of the
> manifest file).

I wouldn't call it stupid ...

> Is there a way of making it work the way I expect it to work (ie
> failing when there are no files in the file set) instead of this
> rather unhelpful way?

Ant's svn contains a version of jar that can be made to not build the
jar at all - or fail, depending on an attribute.  So Ant 1.7 will work
as you'd like it to do.

This doesn't help you now.  The easiest workaround probably is to use
the <zip> task instead of the <jar> task and add the MANIFEST.MF in a
second step.  Something like

<tempfile property="zip" suffix=".zip"/>
<zip destfile="${zip}" whenempty="fail" encoding="UTF8">
   ...
</zip>
<jar destfile="your-target-archive">
  <zipfileset src="${zip}"/>
</jar>
<delete file="${zip}"/>

Stefan

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