Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » Adding a jar to a plugin as "compile only"
Adding a jar to a plugin as "compile only" [message #782962] Tue, 24 January 2012 20:41 Go to next message
Roded Bahat is currently offline Roded BahatFriend
Messages: 152
Registered: August 2011
Senior Member
Hello,
I'm developing a plugin which should aid development of a certain project.
I'd like to be able to use that project's code from within the plugin but it would be very much preferable if the classes were loaded from the user's development environment and not a static jar.
Is it possible to add a jar to an Eclipse plugin while not including said jar in the plugin's classpath while running?
Or will I encounter classloader issues?
Thanks a lot,
Roded
Re: Adding a jar to a plugin as "compile only" [message #783171 is a reply to message #782962] Wed, 25 January 2012 08:04 Go to previous messageGo to next message
Martin Skorsky is currently offline Martin SkorskyFriend
Messages: 112
Registered: July 2009
Senior Member
You can add 'Extra Classpath Entries' in the Build tab of the plug-in Manifest editor.
The description says:'List any extra libraries required on the plug-in's classpath for successful compilation.'

May be the jars have to be in a folder inside the plug-in project, but the jars are not build into the plug-in if they are not selected for the Binary Build or the Source Build.
Re: Adding a jar to a plugin as "compile only" [message #783189 is a reply to message #783171] Wed, 25 January 2012 09:03 Go to previous messageGo to next message
Roded Bahat is currently offline Roded BahatFriend
Messages: 152
Registered: August 2011
Senior Member
I'll give it a try.
Thanks a lot.
Re: Adding a jar to a plugin as "compile only" [message #783476 is a reply to message #783189] Wed, 25 January 2012 19:41 Go to previous messageGo to next message
Roded Bahat is currently offline Roded BahatFriend
Messages: 152
Registered: August 2011
Senior Member
I don't think this works.
I suspect that adding the jars to the "Extra Classpath Entries" automatically builds the jars into the plugin.
When running the plugin with the unwanted jars in the "Extra Classpath Entries", I can see their classes are loaded by org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.
Re: Adding a jar to a plugin as "compile only" [message #783704 is a reply to message #783476] Thu, 26 January 2012 09:06 Go to previous messageGo to next message
Martin Skorsky is currently offline Martin SkorskyFriend
Messages: 112
Registered: July 2009
Senior Member
If the jars (or the folder containing these) are not selected in the build tab of the manifest editor, these jars are not build into the plug-in.
Re: Adding a jar to a plugin as "compile only" [message #783897 is a reply to message #783704] Thu, 26 January 2012 17:26 Go to previous messageGo to next message
Curtis Windatt is currently offline Curtis WindattFriend
Messages: 166
Registered: July 2009
Senior Member
If you are developing plug-ins that depend on each other, PDE will always try to use the plug-in in your workspace over the one in the target.

For example: I have plug-in A in both my workspace and my target platform, then I create a new plug-in project B. I add A as a required plug-in in B. When plug-in B compiles, PDE will get the required code from my workspace project A. If workspace project A is closed, deleted or does not match the version constraints, PDE will instead try to use the target platform.

If for some reason you want to have a dependency on a project not controlled by PDE, you can use the JDT build path properties (right click > properties > build path) to add a dependency on a project. Of course any dependencies will not be known to PDE so exporting, launching, etc. will not work correctly.
Re: Adding a jar to a plugin as "compile only" [message #783951 is a reply to message #783897] Thu, 26 January 2012 20:23 Go to previous messageGo to next message
Roded Bahat is currently offline Roded BahatFriend
Messages: 152
Registered: August 2011
Senior Member
Thanks for the replies.
I probably did not explain myself properly.
I'm developing a plugin which is meant to help development of a certain Java project.
I have the odd scenario where I'd like to use some of the classes from that same Java project from within my plugin, but would also like the plugin to use the classes in the Java project on the target platform when running.
I suspect this is not a healthy requirement..
Re: Adding a jar to a plugin as "compile only" [message #784469 is a reply to message #783951] Fri, 27 January 2012 15:21 Go to previous messageGo to next message
David Wegener is currently offline David WegenerFriend
Messages: 1442
Registered: July 2009
Senior Member
It is not a good idea to load classes from users development projects into the VM running Eclipse. In fact, it can be dangerous since you don't have control over the code that is getting loaded. If the users code calls System.exit, Eclipse will exit. This is an extreme example, but there are also other problems dealing with loading/unloading of the class when the user makes a change, etc.

You need to follow the PDE method where you launch a second runtime instance of Eclipse that includes the created class files to allow the user to test out their code.
Re: Adding a jar to a plugin as "compile only" [message #785121 is a reply to message #784469] Sat, 28 January 2012 14:06 Go to previous message
Roded Bahat is currently offline Roded BahatFriend
Messages: 152
Registered: August 2011
Senior Member
The final goal is to have all those said classes generated by the same plugin, if that makes a difference regarding the choice of method.
The target platform does not contain an plugin project but a Java project, so running a new runtime instance is less intuitive.
Previous Topic:Adding new markers
Next Topic:Conditional file build in feature
Goto Forum:
  


Current Time: Tue Jun 28 23:09:17 GMT 2022

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

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

Back to the top