Tycho Target Trouble

I lost a few hours this weekend over one line in a maven pom.xml file.  I thought I would post the issue here so that anyone else that runs into this problem might find some help.  The original setup is this:

I have a fairly large Eclipse based application that I am moving from Juno to Kepler.  I am currently using the Maven/Tycho build structure, so I decided to incorporate a Target Platform definition to make it easier for other developers to set up their target platform as they also move to a Kepler install for their IDE.  I created a project with a target platform and copied a pom.xml file from another project.  I set the packaging to “eclipse-target-definition”.  I added all of the dependencies to the target platform definition and set it as the target platform and was able to build successfully with Eclipse.

When I tried to build with maven, the build (even a clean) would fail immediately with “Could not resolve target platform specification artifact”.  After reading a few pages of google search results, I downloaded the Tycho demo project from here: http://git.eclipse.org/c/tycho/org.eclipse.tycho-demo.git

The itp04-rcp project has a target platform, and I could not see any differences between the demo pom.xml and mine.  I moved my target definition into the demo project and did not see the same error, so I determined that it was not an issue with the target definition itself.  After a few hours of tweaking, I finally figured out that you can’t have a version element in the pom.xml file for a target platform.

I removed the version element and was able to build and install my products.  Now I’m off to the races with Kepler!

Eclipse Communications Framework

A Forensic Approach

A few months ago, I started looking into using Eclipse ECF to provide a mechanism for moving some OSGi services to a remote OSGi paradigm.  The problem that I very quickly ran into is that ECF has the least amount of documentation of any Eclipse project that I have used.  Much of the documentation is also geared toward developers who want to develop new protocols, containers, discoverers, etc.  I do not want to develop ECF, I want to use it!

Of course, after my rant about lack of documentation, I found that the ECF team is working on an ECF Users Guide.

After a few days of Google exercises, I decided to go to the source and see what I could figure out for myself.  I started by cloning the ECF repository available here: ECF Git Repository and then loaded all of the projects into a new workspace.

The Tests

I checked my Run Configurations and found that there were now several JUnit Plugin tests created from launch configurations included in the test projects.

ECF Run Configurations

I launched each of the tests and found that most completed successfully.  I was a bit surprised, since I still had several compile issues in the source.  As it turns out, the compile issues were either due to missing dependencies or were bundles in an incubation directory:

  • There are a few ECF SDO plugins that depend on EMF SDO
  • The mylyn plugin had compile issues (probably because I’m running Kepler)
  • There is an ECF provider (and test) for dnsdd that has a dependency on org.xbill.dns
  • There is an ECF provider (and test) for zookeeper that has a dependency on org.apache.hadoop.zookeper
  • There is an ECF plugin with import dependencies on the Spring Framework
  • The REST capabilities have a dependency on org.json
  • There are twitter bundles that I assume have a dependency on some Twitter packages.

The tests that did not use these items seemed to run correctly.  This was important to me so that I could get a baseline of working code to use as a comparison for my learning experiences.

The Examples

The other great way to learn from the code is to check out all of the example projects that are included in the repository.  There are several example client and server bundles with run configurations that show how the different configurations are set up to connect.

For distributed OSGi, there are different configurations of the same remote connection:

  1. Declarative Services or register the service programmatically
  2. Service Discovery or static endpoint configuration
  3. If using Service Discovery, pick from SLP, Zookeeper, or Zeroconf
  4. r-OSGi or ECF Generic
  5. Synchronous or Asynchronous with callbacks

I was able to learn a great deal about how the remote OSGi can be configured by focusing on the commonality and differences between the examples:

ECF Example Projects

All in all, I was able to get my services working in a few different configurations.  I still have a good bit of work to do because I was using EMF objects as parameters of my service methods, and EMF objects are not serializable without some extra code.  But that’s a post for another day…

Fun with Google CodePro

Usually when a software tool has “Pro” in the name, it means that it is expensive. Sometimes it just means that the features are unlocked so that you can actually use the tool. In this case it means FREE.

I have used CodePro on another project, but started using it again to help analyze the Stanford Natural Language Parser (also free).  I would like to use the StanfordNLP in a side project that I have in mind.  The problem is that is has a large code base in a domain (language parsing) that I am not familiar with.

I will have to split this into multiple posts, but you can read about the metrics report below.

Continue reading

Eclipse Console Window

Here’s a quick code snippet for using the Console view that is included with the standard Eclipse views when using RCP.  In the example, I am using the output from Log4J and streaming it to the Console.

The Console import declarations are:

import org.eclipse.ui.console.ConsolePlugin;
import org.eclipse.ui.console.IConsole;
import org.eclipse.ui.console.IConsoleManager;
import org.eclipse.ui.console.MessageConsole;

The code that you will need to create the Console and direct the Logging output to the console is:

// Connect the Logging output to the console view.
ConsolePlugin plugin = ConsolePlugin.getDefault();
IConsoleManager consoleManager = plugin.getConsoleManager();
MessageConsole console = new MessageConsole("Console", null);
consoleManager.addConsoles(new IConsole[] { console });

logger = Logger.getLogger("default");
logger.addAppender(new WriterAppender(new SimpleLayout(), console.newMessageStream()));

And that is basically it. All output to the logger is now streaming to the Console window in the application.

Overlay Icon

I had a good bit of trouble in Eclipse with taking an Icon and adding another Icon as an overlay. This was needed for creating an ILabelDecorator for the Common Navigator. I found a few posts on different forums that used a class called OverlayIcon from a package in Eclipse. The problem was that I didn’t seem to have that package installed, or just didn’t have access to the class.

It took forever, but I finally found a class that works. It was posted in a user folder from LSU of all places. It is from the package org.eclipse.team.internal.ui, which was available for import with my plugin.xml file. The problem is that it does not contain the OverlayIcon class. So I would up using the source from the link below and putting it in my own package.

Here’s a link to where I found this code: Link to OverlayIcon

Also, here is a copy of the code (with package removed) in case the link above is ever broken:

Continue reading