@SuppressWarnings("unchecked")
private java.util.jar.Manifest createJarManifest() {
java.util.jar.Manifest newManifest = new java.util.jar.Manifest();
newManifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
Section mainSection = mft.getMainSection();
Enumeration<String> mainAttributes = mainSection.getAttributeKeys();
while (mainAttributes.hasMoreElements()) {
String aname = mainAttributes.nextElement();
String avalue = mainSection.getAttributeValue(aname);
newManifest.getMainAttributes().putValue(aname, avalue);
}
// OSGI Export-Package
if (!StringUtils.isEmpty(version)) {
String vString = MessageFormat.format(";version=\"{0}\",", version);
StringBuilder packages = new StringBuilder();
for (String packageName : exportedPackages) {
packages.append(packageName);
packages.append(vString);
}
if (packages.length() > 0) {
packages.setLength(packages.length() - 1);
newManifest.getMainAttributes().putValue("Export-Package", packages.toString());
}
}
// for (Map.Entry<Object, Object> entry : newManifest.getMainAttributes().entrySet()) {
// System.out.println(entry.getKey() + "=" + entry.getValue());
// }
Enumeration<String> sections = mft.getSectionNames();
while (sections.hasMoreElements()) {
String sname = sections.nextElement();
Section section = mft.getSection(sname);
Attributes newAttributes = new Attributes();
newManifest.getEntries().put(sname, newAttributes);
Enumeration<String> attributes = section.getAttributeKeys();
while (attributes.hasMoreElements()) {
String aname = attributes.nextElement();
String avalue = section.getAttributeValue(aname);
newAttributes.putValue(aname, avalue);
}
// for (Map.Entry<Object, Object> entry : newManifest.getAttributes(sname).entrySet()) {
// System.out.println(entry.getKey() + "=" + entry.getValue());