Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I attach source code locations to plugins in my Eclipse RCP target platform?

I've got a workspace with multiple RCP plugin projects.

We've set the target platform, so we can build against a standard set of plugins, but are not able to see source code and Javadoc for all the platform plugins.

The Windows -> Preferences -> Plug-in Development -> Target Platform -> Source Code Locations page doesn't seem to have any effect when I add the eclipse directory (it only allows you to add directories).

Copying the source jars from the eclipse directory into the target platform has a similar effect.

What am I doing wrong? How do I attach a set of Source jars to my target platform?

like image 408
jamesh Avatar asked Oct 27 '08 19:10

jamesh


People also ask

How to find source in Eclipse?

In either your Package or Project Explorer view, right-click on the JAR to which you would like to attach source code and select Properties. You will be presented with a dialog that allows you to specify a location for the corresponding source code. Alternatively, right-click on your Java project and select Properties.

How to download source code in Eclipse?

Usage: Right click on a Java library of a Java-based project and choose the menu item "Attach Java Source" and wait for the source code to be downloaded/attached to the library automatically (you will see a background job is running on Eclipse status bar).


2 Answers

I had the same problem today. In my case I wanted to debug into the source of the plugin embedded jetty (org.mortbay.jetty_5.1.14.v200806031611.jar) which comes with Eclipse Equinox (OSGI) which is part of my eclipse target platform.

When debugged and wanted to go into any class inside a jetty package I always got the message that it is a class from Plugin-Dependencies and the source attachment cannot be modified.

I solved it like this:

  1. Switch to the Plugins View in Eclipse ( Window / Show View / Plugins)
  2. locate the bundle org.mortbay.jetty
  3. right click on that bundle and select "Import as" -> "Binary Project with linked content"

Now that Bundle shows up in your Package Explorer as a new Eclipse project, in my case org.mortbay.jetty.

Now right click on that new project in the package explorer and goto 'Properties / Java Build Path / Libraries'. You see the the jetty jar file there and if you expand this entry you can edit the 'Source Attachment' as usual. I pointed it to the downloaded Jetty Source code located in a completely different folder than my target platform which I am using for my project.

like image 133
Christoph Avatar answered Sep 28 '22 06:09

Christoph


If you use Eclipse SDK bundles when building your target platform, you should be immediately provided with "Java Source Attachment" and "Javadoc Location" for each Eclipse plugin. For example, I used "Eclipse Platform SDK" (eclipse-platform-SDK-3.4.2-win32) as target space and when I display the "Source Code Locations page" that you mentionned, it is filled with "Source locations declared in the target platform". In the Eclise IDE, I can then see Eclipse core plugins source code and javadoc (in JFace packages for example).

Otherway, it is not so easy to add plugins source code locations but you can succeed it in 2 ways :

  • providing a "source plugin" (the easiest way if the plugin provider also supplies the source plugin) into the target platform, as an ordinary plugin (PDE will recognise it)
  • providing an additional source location (not the easy way ...)

You can find more information about Target Source Code Locations in you Eclipse Help, in the following topic : Plug-in Development Environment Guide > Tools > Preferences > Target Platform Preferences > Source Code Locations

like image 31
JM.D Avatar answered Sep 28 '22 04:09

JM.D