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

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?

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:
Switch to the Plugins View in Eclipse ( Window / Show View / Plugins)
locate the bundle org.mortbay.jetty
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.

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

All sources are available if you download the 'Eclipse for RCP and RAP Developers' build from the main downloads page. At least, that's what it's called for the Juno build, it used to be called Eclipse for RCP/Plug-in Developers.
It doesn't look like the plugin source code is available via the standard Java/J2ee Eclipse builds any longer. I was assuming the sources would be available via the update mechanism but have been unable to find the correct update site/feature. If anyone knows, please comment.

I can modify the target platform at runtime, using the -install runtime option. Keep the targetPlatform as the eclipse platform.
However, this loses a lot of the benefits of using a target platform in the first place - i.e. compile time safety.

Related

Eclipse Kura OSGi Dependency Management

Preface: I'm new to Eclipse, OSGi, and Kura
I'm trying to develop a Kura plug-in that depends on org.apache.httpcomponents.httpclient. I found an OSGi bundle for the package here.
Currently, the only way I'm able to use the plug-in (with the OSX Kura emulator) is to download httpclient-osgi-4.5.jar and add it to ~/Documents/workspace/target-definition/common/repository/plugins/. Otherwise I get a class not found error.
When I add the plugin to MANIFEST.MF either as with REQUIRE-PLUGIN or IMPORT-PACKAGE, Eclipse cannot find the package.
What's the correct way to require, fetch, and add to the classpath a remote dependency using Eclipse Kura/OSGi? Eclipse currently only looks in my local workspace for dependancies, is there an accepted way to fetch remote plugins?
Thanks for the help!
The bundles located in target-definition/common/repository/plugins are part of an M2 repository created by the Kura build. It is not enough to simply copy your required bundle to that directory. The solution I typically use to accomplish what you want is:
Double click the kura-equinox_3.8.1.target file located in target-definition. This should open in the Eclipse IDE.
Under "Locations", click "Add...". Then select "Directory" and "Next". Select the folder containing your required additional bundles and click "Finish".
Save the kura-equinox_3.8.1.target file and click "Set as Target Platform". Your new bundle should now be available in Eclipse.
Thanks,
--Dave
What for me works is;
Simply copied the bundle in ${workspace_loc}/target-definition/common/repository/plugins
Clicked on reload
Clicked on Set as Target Platform
After these steps, Eclipse is aware of my bundle and could able to use it anywhere.

How to find the execution steps of an Eclipse plugin project

I am using Eclipse JUNO IDE in which I have imported an eclipse plugin project.
When I execute the project, a new copy of the eclipse window is opened and the plugin is displayed in the File Menu as "New Sample Project" in between the "New" option and "Open File" option. The plugin works normally.
From this project I wanted to know which file executes first and how the execution proceeds.
While this is the way to find the order of execution of a simple java program, is there a way to find the code execution order of a plugin project, which has many packages and each package has many java files?
I am new to eclipse plug-in development. Please help
Eclipse plugin project is different than normal Java project and also its execution.
Before jumping into execution steps, I think you better go through plugin project Manifest file details. It will give you overview of plugins that are contributed into your new eclipse instant and their implementation class in project.
Go through different tab in the manifest file. I will brief some of important things for you:
Overview: General info of you plugin. In general information section you will find Activator, which points your activator of plugin which will load your plugin.(You can say it as starting point as it controls plugin life cycle but not clearly starting point)
Dependencies: Plugins required and on which your projects are depended.
Extension: Here you will add Extension Points required for your plugin like view, editor, action,command. Here you can see overview of things which will be contributed through your plugin project.
Hope this helps.

Easy way to find which Eclipse version and plugins are needed for existing Eclipse project

I was given a working Eclipse project in Java. If I open it in some version of Eclipse then I get numerous errors. I get them because my version of Eclipse differs (it is not web developer) and vaadin and ivy plugins were used to create the project. How can I understand which version of Eclipse and which plugins are needed? I can get some sense by looking in .setting folder. There are a lot of files with names as namespaces related to plugins. Is there more direct or automatic/semi automatic way to find which plugins and Eclipse version are needed?
No. The Eclipse developers expect you to know your tools and if you take over a project from someone else or join a project, that someone explains to you how to install and configure Eclipse.
To find out which Eclipse plugins you need, look into the file .project and the folder .settings. Google for the file names and plugin IDs to see what they might mean. Usually, the third word of the name is the project (org.eclipse.jdt.* -> JDT project).
For missing classes, you need to look at the classpath. The easiest way to do that is to right-click on your project name and then select "Properties" from the menu. There is an entry "Build Path" which contains all the dependencies. Click through the tabs to see what you need.
For plugin projects, look into the file META-INF/MANIFEST.MF; Eclipse should open a special editor when you open it which has a tab for dependencies.

Debugging eclipse e4 source code

I have an Eclipse e4 RCP project using the compatibility layer.
The targets include org.eclipse.e4.* plug-ins and their source code. For example:
$ ls org.eclipse.e4.core.di*
org.eclipse.e4.core.di.extensions.source_0.12.0.v20140417-2033.jar
org.eclipse.e4.core.di.extensions_0.12.0.v20140417-2033.jar
org.eclipse.e4.core.di.source_1.4.0.v20140414-1837.jar
org.eclipse.e4.core.di_1.4.0.v20140414-1837.jar
The launcher configurations include the plug-ins without source code.
Source code for classes within those plug-ins is not being found with Navigate>Open Type or when debugging. In the debugger, I'm given a button Edit Source Lookup Path -- but I'd like the source path to automatically update when I switch targets.
I can make that happen by adding these plug-ins to the manifest of one of my plug-ins. However, these are not direct dependencies, and it seems inelegant to list these here.
Adding the plug-ins to the product configuration file does not appear to help.
How can I automatically access the current target's source code within the org.eclipse.e4 packages, when debugging, and when using Navigate>Open Type?
You include the target platform plugins in the Java searches (including Navigate > Open Type) by checking the
Include all plug-ins from target in Java search
check box on the Preferences > Plug-in Development preference page.
The first time after this that you use Navigate > Open Type or another search it may be a bit slow while the Java indexer runs on the extra source files. It should run normally once the indexes are built.

How to use SVN to build a library

I am trying to follow a tutorial, and I am told to:
1- Get the source code for the Java EMV Reader library from http://code.google.com/p/javaemvreader/ and build it.
2- Drop the resulting jar file in lib/.
3- Import the project in Eclipse and build it.
I right click the java files, and choose run as but don't get an option to run as Java Application. I also can not export the files as a JAR file. I have enclosed an image of what I have
After the first comment, I right clicked on my project, and under Maven, chose the option "configure as Maven" project. ( Thank you so much; this must be one of the fastest resolutions in the world )And I can now run the project. I get the window in my pic2, which I have attached. I don't however know what step 2 of the above instructions means. I don't see a lib/ folder. And the project he is refering to in step 3 is on git. Any ideas on what he means? ![pic2]!1
Eclipse projects have a "type" and that controls what tools are available. You probably created a "Basic Project" which means there are no compilers or other Java tools associated with it. You would want to create a Java Project in Eclipse.
That project does not seem to have Eclipse .project and .classpath files checked into the repository. It does look to be a Maven project however. So you would either want the m2eclipse plugins installed, and check this out as a Maven project, which would handle configuring everything else, or you want to use the Checkout As ... option and use the wizard to create a new Java project to checkout.
These are more Eclipse IDE questions than SVN or Subclipse questions.