Building Deployment Packages for Kura

Taking advantage of the creation of the Git repository for Jura, we made several commits in order to exemplify the process of adapting a Kura application project to the deployment mode recommended here

3 comments

commitOSGi is ideal for managing IoT gateways and we believe that it is a wise move that Kura has been developed using it. It is difficult to explain OSGi in a simple way and it may be even more difficult to explain its benefits (http://tuhrig.de/when-modularity-comes-down-to-osgi/). For us, Kura is one of the best examples to prove the suitability of OSGi in certain scenarios.

Taking your first steps in Kura can be very hard if you have no experience with OSGi, but we encourage you to persevere as we believe this effort is worthy. Although we are not OSGi experts, before using Kura we suspected that building and deploying applications would be complex; even though this process is not as complex as using with other tools, it is not trivial.

There is no single way to build and deploy applications in Kura. Knowing that it could be a complex process and after trying different ways of doing it, we decided to write this short guide explaining the best way of doing it based on our experience. Taking advantage of the creation of the Git repository for Jura (one part of our proposal), we made several commits in order to exemplify the process of adapting a Kura application project to the deployment mode recommended here.

Before we start we want to warn the reader that we have a little experience with some of the tools that we are using. For this reason, if something of what we do is weird and it shocks you and you think that it could be done better, surely you might be right, so please let us know 😉

First of all, we started with an Eclipse installation in which the Kura repository was imported. If you do not know how to do it you can solve your questions reading the following links: link1 and link2.

Once, we had the Kura repository in the directory <develop>/kura and we created a general Eclipse project for Jura in the directory <develop>/jura (the route from Jura to Kura is ‘../kura‘), we made the first commit with the newly created project.

After that, it was time to create our first Jura plug-in, iot.challenge.jura.util, a plug-in of utilities. When we created it, we unchecked the option ‘Use default location‘ and specified the directory <develop>/jura/iot.challenge.jura.util. For newcomers to Kura, here you will find a guide to creating plug-ins.

The plug-in uses Lombok. Notice that we are going to use this library in other plug-ins, so we decided to convert it into an OSGi plug-in. To do so, we downloaded the library and used it to create the lombok plug-in on the directory <develop>/jura/lombok. Here it is explained how to perform this conversion.

Once we had the lombok plug-in with all its packages exported in its manifest and after the lombok package was imported by iot.challenge.jura.util plug-in, we could compile both plug-ins using Eclipse. At this point, we made a new commit.

Notice that the Lombok project is a bit different from the usual. If this is new to you and you decide to use it, you should know that you must configure it in your IDE. Here you can find a quick introduction with everything you need to know to start using it.

In order to easily build the plug-ins without using Eclipse we used Maven, specifically Tycho. To do this, we first converted all the projects (jura, iot.challenge.jura.util and lombok) into Maven projects by selecting them in Eclipse, secondary-click Configure > Convert to Maven Project.

As we advanced, we used Tycho, having at our disposal a project that uses Tycho, Kura. Starting from the pom.xml of Kura and the pom.xml of one of its plug-ins we adapted the pom.xml files of jura, iot.challenge.jura.util and lombok. At this stage we made a new commit.

Clarification
We said that Lombok is a bit special, this also affects its Tycho integration. Lombok is purely a building dependency so it should not be necessary to generate a plug-in and having it available at runtime (you can see a non-OSGi example here). In our case, after trying several configurations, it only worked in the way described here. Since the name of this guide is ‘Building Deployment Packages for Kura’ and not ‘How to integrate Lombok in Tycho’ we can move on 🙂 . By the way, if you use Lombok in the same way that we are using it, you should make a ‘mvn install’ of it. After doing that, you could build any plug-in that depends on it.

Update on 3rd February
Our apologies. After several tests, we think that currently it is not possible to integrate Lombok into Tycho (maybe the reason is this). The use that iot.challenge.jura.util makes of Lombok does not cause any problem (only a @NonNull annotation). We have verified using Lombok in a more complex scenario that it does not work correctly. However, this does not affect the guide (remember its name 😉 ) . By the way, do not misjudge Lombok, it is a great tool!

Returning to the guide, at this point we had two Kura plug-ins that we could build using Maven. In the following step, we wanted to deploy both plug-ins with a single package. To do so, we used the Maven plug-in OSGi distribution package builder. First, we created a new Eclipse feature project with the name iot.challenge.jura.util.feature in the directory <develop>/jura/iot.challenge.jura.util.feature and convert it into a Maven project. The feature includes the plug-ins iot.challenge.jura.util and lombok  (this can be checked here).

We modified the Jura pom.xml to include the OSGi distribution package builder plug-in and the new module. After that we modified the feature pom.xml (be careful with the packaging directive) and, that’s it!

The Maven construction of the feature generated a DP file that can be deployed in Kura. At this point, we made a final commit.

util-dp

3 comments on “Building Deployment Packages for Kura”

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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