Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Exported libraries imports to runtime-workspace plugins.
Exported libraries imports to runtime-workspace plugins. [message #156753] Sun, 25 April 2004 07:43
Eclipse UserFriend
Originally posted by: stoyle0905.hotmail.com

Hi.

I am developing a code generation plugin, and I am having a problem with
importing exported libraries.

The scenario is like this:

In my runtime workbench i have several plugins for a code generation
facility, e.g. one for the model, one for general code generation and
several for a targeted platforms.

When the code generator runs it creates a new project where it puts the
source files. JDT compiles these files, but there are compilation errors
because the source files requires specific libraries from the targeted
platform.

These libraries may of course be imported manually in the worckbench, but it
would be a lot nicer if the imports were done automatically.

In the target platform plugin, I've exported these libraries and I would
like to import them into my new project. It seems there is a problem with
getting these libraries, even though I think I am using the correct
procedure of getting it, or maybe not...

When analysing the problem it seems that the method

JavaCore.newLibraryEntry(path, sourcePath, sourceRootPath);

has problems finding the entry, if the referenced path is inside a zip file.
If I understand the runtime workbench correctly, it packages the workspace
plugins in a plugins.zip file when lauched. I am sure there wouldn't be a
problem if I actually exported the workbench plug-ins and used them with
Eclipse, but the plug-ins are a bit immature, so I would rather wait.

Any ideas, any comments? Help would be greatly appreciated.

The code I have written looks something like this:


....
IJavaProject destinationProject = ...

MyPlugin plugin = MyPlugin.getPlugin();
IPluginDescriptor desc = plugin.getDescriptor();

URL installUrl = desc.getInstallURL();

IPath p = new Path(installUrl.toString());

ILibrary[] libraries = desc.getRuntimeLibraries();

List tmp = new ArrayList();

for (int i = 0; i < libraries.length; i++) {

if (libraries[i].isExported()) {

IPath path = new Path(p.toString() +
libraries[i].getPath().toString());

tmp.add(JavaCore.newLibraryEntry(path, null, null));

}

}

Object[] o = tmp.toArray();

IClasspathEntry[] entries = new IClasspathEntry[o.length];

System.arraycopy(o, 0, entries, 0, o.length);

destinationProject.setRawClasspath(entries, monitor);

....


Just so it is clear, I have tried different methods on the installUrl URL
object, and noen seem to work.

Thanks for all your help.

Kind regards
Alf Kristian St
Previous Topic:Multiple class in one file
Next Topic:Automatically adding JRE System Library in new IJavaProjects
Goto Forum:
  


Current Time: Wed Jul 17 15:39:46 GMT 2024

Powered by FUDForum. Page generated in 0.02897 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top