Bug 33026 - jar task fails when zipgroupfileset contains zip files without manifest
Summary: jar task fails when zipgroupfileset contains zip files without manifest
Status: NEW
Alias: None
Product: Ant
Classification: Unclassified
Component: Core (show other bugs)
Version: 1.6.2
Hardware: All All
: P2 enhancement (vote)
Target Milestone: ---
Assignee: Ant Notifications List
Depends on:
Reported: 2005-01-10 11:02 UTC by Karl
Modified: 2008-11-24 03:58 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Karl 2005-01-10 11:02:55 UTC
A NPE terminates the jar task if a zipgroupfileset is used to add a jar file
that doesn't contain a valid MANIFEST.MF entry.

<jar destfile="bfj.jar" filesetmanifest="merge">
	<zipgroupfileset refid="manyjars.fileset" />

Source : ant/src/main/org/apache/tools/ant/taskdefs/Jar.java

private Manifest getManifest(Reader r) {

	Manifest newManifest = null;
	try {
		newManifest = new Manifest(r);
	} catch (ManifestException e) {
		log("Manifest is invalid: " + e.getMessage(), Project.MSG_ERR);
		//throw new BuildException("Invalid Manifest: " + manifestFile, e,
getLocation()); // <-- here!
		return null; // <-- and here!
	} catch (IOException e) {
		throw new BuildException("Unable to read manifest file"
								 + " (" + e.getMessage() + ")", e);
	return newManifest;

The method getManifest(Reader) throws a BuildException if a source jar has a
invalid manifest, this is correct but can be annoying if you want to merge in
the jar file despite the invalid entry. Perhaps an option should decide wheiter
this function should throw an exception or just return null to allow merging of
third party jars with invalid manifests.
Comment 1 Peter Reilly 2006-09-08 10:54:14 UTC
Changing title as NPE happens only if you change the code.