Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Add my plugin to new Java project classpath
Add my plugin to new Java project classpath [message #1689435] Mon, 23 March 2015 11:19 Go to next message
Eclipse UserFriend
Hi,

I want to add my plugin jar file to a newly created Java project.

I am doing it with this code but I wonder if there is a better/cleaner way to do it. The path used seems to be likely to change once my plugin is updated, so any existing projects would be broken.

I thought maybe of adding a library variable and using something similar, so that the project references the library and will be correct if the path ever changes.

    URL url = new URL("platform:/plugin/" + MyPlugin.PLUGIN_ID);
    String path = FileLocator.toFileURL(url).getFile();
    IClasspathEntry pluginEntry = JavaCore.newLibraryEntry(new Path(path), null, null);


Francisco

[Updated on: Thu, 26 March 2015 19:26] by Moderator

Re: Add my plugin to new Java project classpath [message #1690367 is a reply to message #1689435] Thu, 26 March 2015 18:19 Go to previous messageGo to next message
Eclipse UserFriend
Have you seen the extension point "org.eclipse.jdt.core.classpathVariableInitializer"?

Also extension point "org.eclipse.jdt.core.classpathContainerInitializer" might be of interest.

In the first case you can declare classpath entries as "MYVAR/somePlugin.jar", whereas the second extension point allows to reduce it to "MYCONTAINER", avoiding also problems with version numbers that might be part of your plugin jar.
Re: Add my plugin to new Java project classpath [message #1690371 is a reply to message #1690367] Thu, 26 March 2015 19:26 Go to previous message
Eclipse UserFriend
Thanks for the reply.

Is there a better way to get my plugin jar file path? The code sample I posted just gets the path to the plugin but it is for the classes, not for the jar itself. I think that a path to the jar would be cleaner.
Previous Topic:"cannot be cast" error
Next Topic:Java n-node tree
Goto Forum:
  


Current Time: Thu Apr 17 21:48:01 EDT 2025

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

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

Back to the top