|
java.util.jar.Manifest does basic validation of the format. It could always be extended to do more robust validation. 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. Simple testcase for this issue - I will try to do the fix later... 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 complete Eclipse prject to demonstrate usage of the Package API Link directly to the Maven issue 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. Patch applied with some modifications. Thanks! 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. For non-standard attributes you should use a custom manifest file with the maven.jar.manifest property. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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