Issue Details (XML | Word | Printable)

Key: MPJAR-36
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Critical Critical
Assignee: Lukas Theussl
Reporter: Eugene Kuleshov
Votes: 2
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
Maven 1.x Jar Plugin

Jar plugin generate incorrect manifest file

Created: 05/Aug/04 12:58 AM   Updated: 29/Jul/08 02:48 AM
Component/s: None
Affects Version/s: 1.5
Fix Version/s: 1.8

Time Tracking:
Not Specified

File Attachments: 1. Zip Archive jartest.zip (2 kB)
2. Zip Archive maven-1415-testcase.zip (9 kB)
3. Text File patch.txt (5 kB)

Issue Links:
Related
 
dependent
 


 Description  « Hide
Current jar plugin genrate an invalid manifest file. In particular it is impossible to retrieve package version information for jars created by this plugin. See more details at http://java.sun.com/j2se/1.4.2/docs/guide/jar/jar.html#JAR%20Manifest

Here is the example of current generated manifest file:

----------
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.5.3
Created-By: Apache Maven
Built-By: Administrator
Package: org.codehaus.activemq.jms.cci
Build-Jdk: 1.4.2_02
Class-Path: commons-logging-1.0.3.jar log4j-1.2.8.jar
Extension-Name: ra-jms
Specification-Title:
Specification-Vendor:
Implementation-Title: org.codehaus.activemq.jms.cci
Implementation-Vendor:
Implementation-Version: 0.0.2

----------

And this is about how it should look like instead:

------------
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.5.3
Created-By: 1.4.2_02-b03 (Sun Microsystems Inc.)
Class-path: commons-logging-1.0.3.jar log4j-1.2.8.jar

Name: org/codehaus/some/component/
Specification-Title: something
Specification-Vendor:
Specification-Version: 0.0.2
Implementation-Title: org.codehaus.activemq.jms.cci
Implementation-Vendor:
Implementation-Version: 0.0.2

--------------------------



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Felipe Leme added a comment - 05/Aug/04 07:08 AM
Eugene,

Is there any tool or Java code that could be used to verify if a Jar file is complaint or not? That would make it much easier to test the fix.

Felipe


Ian Springer added a comment - 05/Aug/04 09:19 AM
java.util.jar.Manifest does basic validation of the format. It could always be extended to do more robust validation.

Eugene Kuleshov added a comment - 05/Aug/04 11:05 AM
I'm not sure if you can do much automatically.

For the manifest from my original comment if package org/codehaus/some/component/ (notice last slash!) have class MyComponent, then the following code should return true:

"0.0.2".equals( MyComponent.class.getPackage().getSpecificationVersion())

I also noticed that standard jarsigner tool is sometimes picky for incomplete manifests, you can try it too.

Thank you.


Felipe Leme added a comment - 06/Aug/04 01:22 AM
Simple testcase for this issue - I will try to do the fix later...

Felipe Leme added a comment - 13/Aug/04 08:25 PM
Eugene,

I couldn't get the package information from any jar that I tested. Could you please attach a jar where your code snippet works? Better yet if it has a main class that already test it.

Felipe


Eugene Kuleshov added a comment - 14/Aug/04 12:43 PM
complete Eclipse prject to demonstrate usage of the Package API

Joerg Schaible added a comment - 01/Oct/04 05:37 PM
Link directly to the Maven issue

Michael Gaffney added a comment - 05/Oct/04 01:55 PM
I've attached a patch to fix this problem. I moved version information about a package from the 'main' manifest section to a package section. I looked at manifest files for other projects (like ant and xalan) and noticed they were also doing it this way. An added benefit is that it would now be possible to correctly merge two jar files and their manifest files.

I deleted the setting of the 'Created-By' attribute because the ant manifest task correctly sets this with the java version used to generate the manifest file (which is what the Sun spec says it should be). This info was previously captured in the non-standard 'Build-Jdk' attribute which I removed because it was redundant.


Lukas Theussl added a comment - 08/Apr/06 12:50 AM
Patch applied with some modifications. Thanks!

wolfgang haefelinger added a comment - 25/Jul/08 07:23 AM
It appears, that there is now no way in Maven 1.1 to add a entry to the Main section. This does not make sense. Of course, Maven should create a "correct" Manifest file. However, why having an opinion about explicitly adding something to the Main section? This patch needs to be improved to allow for attributes in the Main section as well.

Lukas Theussl added a comment - 29/Jul/08 02:48 AM
For non-standard attributes you should use a custom manifest file with the maven.jar.manifest property.