The Object Teams Blog

Adding team spirit to your objects.

Between the Times

with 4 comments

This week is (supposed to be) “quiet week” at Eclipse: Release Candidate 4 is in place and more testing is being done before the final Indigo Release. Time to speak of s.t. that the Object Teams project has neglected a bit in the past: compiling / building with Maven.

Edit (June 2014): In a good tradition of using quiet week I’ve updated the Maven support for OT/J 2.3.0 (Luna).

Compiling OT/J with Maven

In the days of Maven2, pluging-in a non-standard compiler required fiddling with the nexus compiler plugin, which was buggy and all that. With the recent development around Maven3 and Tycho things became easier. The following pom-snippet is all you need to tell Maven to use the OT/J compiler:

                <!-- Use compiler plugin with tycho as the adapter to the OT/J compiler. -->
                    <!-- This dependency provides the implementation of compiler "jdt": -->
                            <!-- Exclude the original JDT/Core to be replaced by the OT/J variant: -->
                        <!-- plug the OT/J compiler into the tycho-compiler-jdt plug-in: -->
Edit (June 2014): As of version 2.3.0 (Luna) the groupId has been changed to org.eclipse.objectteams (meanwhile, 3-part group IDs are the de-facto standard for Eclipse projects).

This relies on the fact, that the OT/J compiler is compatible with the JDT compiler, good.

To make things go smooth in various build phases a few more bits are required:

  • provide the OT/J runtime jar and its dependency (bcel)
  • tell surefire about required command line arguments for running OT/J programs

These basics are collected in a parent pom so that all you need are these two snippets:

        <name>Object Teams Repository</name>
Edit (June 2014): Again: as of version 2.3.0 the groupId is org.eclipse.objectteams.

This converts any Java project into an OT/J project, simply enough, huh?

At least compiling and testing works out-of-the box. Let me know what additional sophistication you need and if adjustments to other build phases are needed.

OT/J over m2e

Well, I’m not much of a Maven expert, but I’m an Eclipse enthusiast, so, how can we use the above inside the IDE?

The bad news: the m2e plug-in has hardcoded its support for the compiler plugin to use “javac” as the compiler. Naive attempts to use tycho-compiler-jdt have failed with the infamous "Plugin execution not covered by lifecycle configuration".

The good news: By writing a tiny OT/Equinox plug-in I was able to remedy those issues. If you have the m2e plug-in installed (Indigo version), the normal “Update Project Configuration” action will suffice:
Update Project Configuration

After that, the project is recognized as an OT/J project, both by the IDE …

… and also by maven …
Running mvn test

Where to get it?

The mentioned plug-in is brand-new and as such it is not part of the regular OTDT distribution. OTOH, the plug-in is so simple, I don’t expect a lot of changes needed. So, if you have an Indigo-ish Eclipse just add this update site:

Then install “Maven Integration for Object Teams (Early Access)”:
Install the Maven Integration for Object Teams

Don’t forget the <repository> and <parent> definitions from above and you should be ready to go! Yesss, sometimes it pays off that OT/J is a kind of Java, a lot of the tooling can just piggy-back on what’s already there for Java 🙂


Written by Stephan Herrmann

June 14, 2011 at 14:56

Posted in Eclipse, Object Teams

Tagged with , , ,

4 Responses

Subscribe to comments with RSS.

  1. Hi Stephan,

    Is it possible to use OTDT with AJDT?

    Right now I see a lot of exception but I’m not sure what’s the cause:

    at org.eclipse.ui.application.WorkbenchAdvisor$
    Caused by: org.osgi.framework.BundleException: The activator org.eclipse.jdt.core.JavaCore for bundle org.eclipse.jdt.core is invalid
    at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleActivator(
    at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(
    at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(
    at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(
    at org.eclipse.osgi.framework.util.SecureAction.start(
    at org.eclipse.osgi.internal.loader.BundleLoader.setLazyTrigger(
    at org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter.postFindLocalClass(
    … 66 more
    Caused by: java.lang.ClassFormatError: Duplicate field name&signature in class file org/eclipse/jdt/core/JavaCore
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(
    at java.lang.ClassLoader.defineClass(
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.defineClass(
    at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClass(
    at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findClassImpl(
    at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClassImpl(
    at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass_LockClassName(
    at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(
    at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(
    at java.lang.ClassLoader.loadClass(
    at org.eclipse.osgi.internal.loader.BundleLoader.loadClass(
    at org.eclipse.osgi.framework.internal.core.BundleHost.loadClass(
    at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleActivator(
    … 72 more



    July 4, 2011 at 12:11

  2. Hi Ivica,

    During the last months our focus was on compatibility with other tools that are part of the Indigo Simultaneous Release. Since AJDT is not part of Indigo this issue had lower priority, but we are aware that potentially the combination of both weavers could cause havoc as your stack trace signifies.

    I’ve opened bug 351085 to track the issue, so if you have more information please add them to the bug.

    On a side note: are you using AspectJ and OT/J within the same project, or is it just for different projects within the same workspace? Naturally, I wouldn’t expect you to *need* AspectJ if you already have OT/J 🙂



    July 4, 2011 at 14:19

  3. I’ve uploaded a 2.1.0-SNAPSHOT version of the above, that:
    – uses tycho 0.14.1 (org.eclipse.tycho namespace)
    – includes OT 2.1 M6 binaries (compiler&runtime)

    To upgrade simply change the parent-pom version.


    April 3, 2012 at 23:34

  4. […] a previous post I showed how the tycho-compiler-jdt Maven plug-in can be used for compiling OT/J code with […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: