Bug 33026

Summary: jar task fails when zipgroupfileset contains zip files without manifest
Product: Ant Reporter: Karl <karl>
Component: CoreAssignee: Ant Notifications List <notifications>
Status: NEW ---    
Severity: enhancement    
Priority: P2    
Version: 1.6.2   
Target Milestone: ---   
Hardware: All   
OS: All   

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" />
</jar>

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.