Hmm... think I found an answer to my problem, though it's not one I like.
>From Jar.java:
public void setWhenempty(WhenEmpty we) {
log("JARs are never empty, they contain at least a manifest file",
Project.MSG_WARN);
}
It seems Jar.java overrides Zip.java's implementation of the setWhenempty method, so
the whenempty attribute is pretty much worthless when used with a Jar.
This may be a discussion better suited to ant-dev, but...
Why? I don't understand the reason for this change, and the cvs log entry isn't very
helpful. Finally, this change means I'm ending up with a bunch of empty JARs in my
classpath, and makes it a lot harder to create a generalized build script for use on
multiple projects.
Kyle
>>> [EMAIL PROTECTED] 01/04/02 09:09AM >>>
I've run into an odd problem recently with the "whenempty" attribute of the <jar>
task.
The following test ant script, when run in a directory containing ONLY the build.xml
file,
creates both jars. This puzzles me; as best I understand the <jar> task, it seems
like
creation of the second jar should be skipped. When I open the jar, it's empty
(excepting
the Ant-generated manifest file). It seems like this problem popped up recently; I
don't
remember having it under Ant 1.3. I'm currently using Ant 1.4 (compiled on September
3 2001).
Bug or (more likely) user error?
Kyle
build.xml
==========
<project name="test" basedir="." default="package">
<target name="clean">
<delete>
<fileset dir="${basedir}">
<include name="*.jar"/>
</fileset>
</delete>
</target>
<target name="package" depends="clean">
<jar jarfile="${ant.project.name}1.jar" whenempty="skip">
<fileset dir="${basedir}">
<include name="*.xml"/>
</fileset>
</jar>
<jar jarfile="${ant.project.name}2.jar" whenempty="skip">
<fileset dir="${basedir}">
<include name="*.html"/>
</fileset>
</jar>
</target>
</project>
build results (with -debug)
========================
package:
FileSet: Setup file scanner in dir D:\Dev3\scripts\perl with patternSet{ includes:
[*.xml] excludes: [] }
[jar] Updating jar since cannot read current jar manifest:
java.util.zip.ZipExceptionThe system cannot find the file specified
[jar] Building jar: D:\Dev3\scripts\perl\test1.jar
FileSet: Setup file scanner in dir D:\Dev3\scripts\perl with patternSet{ includes:
[*.xml] excludes: [] }
FileSet: Setup file scanner in dir D:\Dev3\scripts\perl with patternSet{ includes:
[*.html] excludes: [] }
[jar] Updating jar since cannot read current jar manifest:
java.util.zip.ZipExceptionThe system cannot find the file specified
[jar] Building jar: D:\Dev3\scripts\perl\test2.jar
FileSet: Setup file scanner in dir D:\Dev3\scripts\perl with patternSet{ includes:
[*.html] excludes: [] }
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>