Reputation: 1094
I'm writing a wizard for an eclipse project and want to include another plugin as Require-Bundle
in the Manifest.MF
.
I have the IProject
I want to include, can I access its Bundle-SymbolicName
without parsing the Manifest.MF
? Or are there other ways to avoid manual parsing?
Upvotes: 0
Views: 72
Reputation: 111142
An IProject
may not represent a plug-in and doesn't have any direct API to get a plug-in id.
You can use the normal Java Manifest
class to look at the MANIFEST.MF using something like:
IProject project = ...
IFile manifestResource = project.getFile(new Path("META-INF/MANIFEST.MF"));
if (manifestResource.exists()) {
try (InputStream stream = manifestResource.getContents()) {
Manifest manifest = new Manifest();
manifest.read(stream);
String symbolicName = manifest.getMainAttributes().getValue("Bundle-SymbolicName");
} catch (CoreException | IOException ex) {
...
}
}
This code is adapted from code used by Eclipse PDE to look for the plug-in.
Upvotes: 1