Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Kura » How to build a Kura Deployment Package with Tycho?
How to build a Kura Deployment Package with Tycho? [message #1652374] Thu, 05 March 2015 21:24 Go to next message
Franz Schnyder is currently offline Franz SchnyderFriend
Messages: 8
Registered: February 2015
Junior Member
Hi

I'm currently (trying to) building a MQTT-SN gateway for my Eclipse Open IoT Challenge project with Kura (http://open-iot-challenge.bittailor.ch).

I managed to do the Hello World samples inside Eclipse. Now I would like to setup my plug-in projects so that they are built with Tycho and also so that I can use Eclipse to edit, compile and unit test them. Further I would also like to create the Kura Deployment Package with Tycho/Maven. I also would like to just have the source code of the plug-in projects in the git repository and no binaries of the dependencies (target-platform).

I was able to setup my plug-in projects to build with Tycho but I had to hardcode a link the target-platform of the Kura "Developer's Workspace" I download to my machine for the hello world examples.

I would like to somehow just specify the dependencies (like with maven) and then the build takes care of fetching the binary for the target-platform. I could not find a solution to do this with Tycho without hardcoding the path to the Kura target-platform of the local "Developer's Workspace".

A further problem I could not yet solve is that I would like to use additional bundles like the Paho MQTT client and the Mockito mocking framework. Currently I localy patched them into the target-platform but this is not a sustainable solution.

You find my current code at https://github.com/bittailor/BtIot

I would appreciate and hints and tips how setup my plug-in projects so that they can be clone from the (source code only) git repository and then a mvn clean verify would fetch all the needed dependencies , build the bundles, run the unit tests and finally create the Deployment Package.

I know those are not core Kura questions but heavily related to OSGI and Tycho, but since Kura is based on them I still hope I'm not completely wrong by asking those questions in this Forum.

Thanks and regards
Franz
Re: How to build a Kura Deployment Package with Tycho? [message #1652738 is a reply to message #1652374] Fri, 06 March 2015 01:01 Go to previous messageGo to next message
David Woodard is currently offline David WoodardFriend
Messages: 420
Registered: July 2014
Senior Member
Hello Franz,

The best way to develop applications with Kura is to import the "Developer's Workspace" into Eclipse, then add your new project(s) to the same workspace. If you are writing an application to run in the Kura framework, it must be aware of the available bundles (target platform). If this is what you are doing there should be no reason to make any hard coded references to the target platform.

The target platform is the set of bundles (plug-ins) your application bundle will run against. The target platform is generally reserved for the bundles needed by the core of Kura. For dependencies specific to your application, I would do one of the following:

1. Add them to the classpath of the bundle you are creating [1]
2. Create a separate bundle just for your dependency [2]. OSGi is meant to be modular, so it is okay to have a lot of bundles running

By doing one of the above your dependency can live in your POM file and not effect the rest of Kura. Note, the above only applies to dependencies on standard JAR files. If your dependency is another bundle/plug-in, it will need to be added to the target platform.

You mention the need for the Paho MQTT client. This is already a part of Kura [3]. This is actually a good example of taking a JAR file and converting it to a bundle [4].

I took a look at your code briefly and it looked okay to me. Where are the hard coded dependencies?

[1] http://wiki.osgi.org/wiki/Bundle-ClassPath
[2] http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html
[3] http://download.eclipse.org/kura/releases/1.1.0/docs/apidocs/org/eclipse/kura/data/DataTransportService.html
[4] https://github.com/eclipse/kura/blob/develop/target-platform/org.eclipse.paho/pom.xml

Thanks,
--Dave

Re: How to build a Kura Deployment Package with Tycho? [message #1656125 is a reply to message #1652738] Sat, 07 March 2015 10:58 Go to previous messageGo to next message
Franz Schnyder is currently offline Franz SchnyderFriend
Messages: 8
Registered: February 2015
Junior Member
Hello Dave

Thanks for your fast reply.

Maybe hardcode was the wrong word. My problem is not the dependencies in the bundles/Manifest my problem is on how my build gets the target-platform where it finds all the dependencies. Currently I reference the repositories of the target platform in the parent POM like this:

 <repositories>
 	<repository>
    <id>p2-repo-common</id>
    <url>file:///${project.basedir}/../target-definition/common/repository</url>
    <layout>p2</layout>
  </repository>
  <repository>
    <id>p2-repo-equinox</id>
    <url>file:///${project.basedir}/../target-definition/equinox_3.8.1/repository</url>
    <layout>p2</layout>
  </repository>
</repositories>


Like this they are found during the build and everything builds. But the target-platform is not part of my git source repository. So when you clone my git repository and try to build it with mvn clean verify it fails with:

  [ERROR] Internal error: java.lang.RuntimeException: Failed to load p2 repository with ID 'p2-repo-common' from location file:////<clone location>/BtIot/ch.bittailor.iot.san/../target-definition/common/repository: No repository found at file:////<clone location>/BtIot/ch.bittailor.iot.san/../target-definition/common/repository. -> [Help 1]


So one would need to create/download/? the target-platform manually. To avoid this I could commit the target-platform to the git source code repository. But I really would like not to commit binary dependencies to the source code repository. So I'm looking for a solution like standard maven provides, that one define the dependencies and the URL of binary repositories from where they can be fetched. Then the build takes care of downloading and caching them.

I also recognized that the the Kura Greenhouse Demo has the same issue. So if I clone the Kura Greenhouse Demo repository and try to build it with mvn clean verify it fails with:

[ERROR] Internal error: java.lang.RuntimeException: Failed to load p2 repository with ID 'p2-repo-equinox_3.8.1' from location file:////<clone location>/kura-greenhouse-demo/../kura/kura/target-definition/equinox_3.8.1/repository/: URI has an authority component -> [Help 1]


So maybe I'm spoilt by the maven experience of just doing git clone && mvn clean verify. But I also think this is the base to to introduce an simple Continuous Integration for the project.

So maybe my initial question should have been, how do I create a Kura target-platform for my project without checking the binaries into my source code repository?

Thanks and regards
Franz
Re: How to build a Kura Deployment Package with Tycho? [message #1665695 is a reply to message #1656125] Wed, 11 March 2015 10:54 Go to previous message
Alessandro Da Rugna is currently offline Alessandro Da RugnaFriend
Messages: 43
Registered: December 2014
Member
What about creating a "first-time-setup" script? The script will
1. wget/curl the developer workspace; skip if zipfile already downloaded
2. unzip it under <clone location>/ws; skip if already unzipped
3. SED through pom.xml and replace a placeholder token with the full path to <clone location>/ws/target-definition/equinox_3.8.1/repository/
edit: I created a small example [1] , take a look at setup-pom.sh script. It does work on my machine (OSX 10.10), it may require a little of work to run on other platforms but you get the idea.

You can create a git post-checkout hook to run the script every time you switch branch/pull. If so, I would suggest to save the pom.xml as pom.xml.skeleton and modify/commit this one. Add the main pom.xml to .gitignore, so git will not complain about uncommited modifications when switching branches/pulling etc.

I'm still interested in the original question: How to build a Kura Deployment Package with Tycho? In my example [1] I'm using "eclipse-plugin" as packaging in the pom.xml. If I try to use "bundle" like the Paho example David linked the build breaks.
Can you take a look?


[1] https://github.com/darugnaa/deployment-package-example


My project: Kura web log level changer https://github.com/darugnaa/kura-web-log
My blog: http://darugnaa.github.io

[Updated on: Wed, 11 March 2015 15:00]

Report message to a moderator

Previous Topic:MeshedPi - IoT Long Range Swarm
Next Topic:Suggestion for WSN between node(things) and M2M gateway
Goto Forum:
  


Current Time: Fri Apr 26 00:28:50 GMT 2024

Powered by FUDForum. Page generated in 0.03091 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top