6
votes

According to this post, IDEA uses Osmorc to run OSGi frameworks. It, in turn, uses Pax Runner to launch different framework implementations.

The toolchain in IDEA 11 can only run Apache Felix up to 3.0.2, but I have to run version 4.0.2. Is it possible? Do other OSGi framework launchers exist for IDEA?

1
I was never satisfied with osmorc in IDEA 10, so I ended up just launching org.apache.karaf.main.Bootstrap.main() as a regular java application. That approached works well enough, except that you can't rely on the IDE's compile button.Chris Dolan

1 Answers

6
votes

You can configure the OSGI frameworks that Osmorc uses from the plugin+ project settings. I use IntelliJ IDEA 11.1.2 and Osmorc 1.4.2.

Here is a screenshot where I configure the OSGI container (at IDE Settings-->OSGi) to some local installation of Apache Felix 4.0.1.

OSGi Framework Definiton

You can also define your custom framework/container and then select the desired OSGI framework to use at Project Settings-->OSGI as seen below:

OSGi Framework selection

In order to create Run configurations, you first need to create some OSGi facets. Hopefully, you are also using maven and the maven-bundle-plugin which will greatly reduce the amount of configuration you need to do(since OSmorc automatically syncs with your pom.xml), but even if you do not, you can manually edit the information for creating the bundles.

So, what you need to do next is create some OSGi facets. Go to Project "Structure-->Facets" and add a new OSGi facet for each bundle you wish to create. It you have automatic detection turned on, then the facets maybe already there. If not, then add them manually and then configure them as you see appropriate, like in the following example.

Intellij IDEA OSGi Facet Configuration

Finally edit your "Run Configurations" and add a new OSGi run configuration. Select the framework you wish to use and the bundles you wish to start as well as other parameters, like in the following example:

Intellij IDEA OSGi Run Configuration