Skip to main content



      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 15:41 Go to next message
Eclipse UserFriend
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 03:04 Go to previous messageGo to next message
Eclipse UserFriend
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 04:03 Go to previous messageGo to next message
Eclipse UserFriend
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 14:41 Go to previous messageGo to next message
Eclipse UserFriend
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 04:06 Go to previous messageGo to next message
Eclipse UserFriend
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 12:26 Go to previous messageGo to next message
Eclipse UserFriend
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 15:23 Go to previous messageGo to next message
Eclipse UserFriend
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 10:21 Go to previous messageGo to next message
Eclipse UserFriend
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 09:06 Go to previous message
Eclipse UserFriend
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: Thu Jul 10 06:11:34 EDT 2025

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

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

Back to the top