Manifest file editing for library plug-ins [message #282445] |
Fri, 11 March 2005 17:45  |
Eclipse User |
|
|
|
Hi
I would like to create a library plugin ala junit but for fit and using
the osgi format for 3.1 and beyond. How do I transform the following
into the Manifest file?
<runtime>
<library name="fit.jar">
<export name="*"/>
</library>
</runtime>
thank you.
-H
|
|
|
|
|
Re: Manifest file editing for library plug-ins [message #282936 is a reply to message #282445] |
Wed, 23 March 2005 23:44  |
Eclipse User |
|
|
|
Originally posted by: ifedorenko.rogers.com
This is a multi-part message in MIME format.
--------------080809020606040003080001
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Here is how I solved this problem
1. generated Manifest.mf using plugin manifest editor
2. ran attached program from plugin's root directory
Hugo A. Garica wrote:
> Hi
>
> I would like to create a library plugin ala junit but for fit and using
> the osgi format for 3.1 and beyond. How do I transform the following
> into the Manifest file?
>
> <runtime>
> <library name="fit.jar">
> <export name="*"/>
> </library>
> </runtime>
>
> thank you.
>
> -H
--------------080809020606040003080001
Content-Type: text/plain;
name="GenerateManifest.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="GenerateManifest.java"
package test.eclipse.manifest;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
public class GenerateManifest {
public static void main(String[] args) throws IOException {
InputStream is = new FileInputStream("META-INF/MANIFEST.MF");
Manifest m;
try {
m = new Manifest(is);
} finally {
is.close();
}
Attributes a = m.getMainAttributes();
String o = a.getValue("Bundle-ClassPath");
StringTokenizer st = new StringTokenizer(o, ",");
Set<String> packages = new HashSet<String>();
while (st.hasMoreTokens()) {
addPackages(packages, st.nextToken());
}
StringBuilder sb = new StringBuilder();
for (String p : packages) {
sb.append(p).append(',');
}
a.putValue("Provide-Package", sb.substring(0, sb.length() - 1));
OutputStream os = new FileOutputStream("META-INF/MANIFEST.MF");
try {
m.write(os);
} finally {
os.close();
}
}
private static void addPackages(Set<String> packages, String filename) throws IOException {
ZipFile jar = new ZipFile(filename);
Enumeration entries = jar.entries();
while (entries.hasMoreElements()) {
ZipEntry entry = (ZipEntry) entries.nextElement();
if (entry.isDirectory()) {
String dir = entry.getName();
packages.add(dir.substring(0, dir.length() - 1).replace('/', '.'));
}
}
}
}
--------------080809020606040003080001--
|
|
|
Powered by
FUDForum. Page generated in 0.04019 seconds