Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Kura » How to create DP package with Maven via command line(How to create DP package with Maven via command line)
How to create DP package with Maven via command line [message #1695490] Fri, 15 May 2015 09:24 Go to next message
Giovanni Persia is currently offline Giovanni PersiaFriend
Messages: 3
Registered: March 2015
Junior Member
Hi All,
I want to build a project using Maven via command line, in order to creates a Deployment Package file of all OSGI bundles.

I are able to create the DP file using the Eclipse GUI with mtoolkit plugin but we need to make it runnuble at command line.

Does anybody already managed that?

Thank you
Giovanni
Re: How to create DP package with Maven via command line [message #1695492 is a reply to message #1695490] Fri, 15 May 2015 09:45 Go to previous messageGo to next message
Alessandro Da Rugna is currently offline Alessandro Da RugnaFriend
Messages: 43
Registered: December 2014
Member
There was another thread about this, https://www.eclipse.org/forums/index.php/t/1028830/ but AFAIK nobody has a working/easy solution.
I personally build my projects with Maven and then manually create the Deployment Package with a shell script. You can see a small example here: https://github.com/darugnaa/deployment-package-example/blob/master/org.darugna.alessandro.webexample/make_deployment_package.sh


My project: Kura web log level changer https://github.com/darugnaa/kura-web-log
My blog: http://darugnaa.github.io
Re: How to create DP package with Maven via command line [message #1695496 is a reply to message #1695492] Fri, 15 May 2015 10:16 Go to previous messageGo to next message
Amit Kumar Mondal is currently offline Amit Kumar MondalFriend
Messages: 108
Registered: March 2015
Location: Munich, Germany
Senior Member

Hi,

I would like to propose a solution which would definitely be very easy in building a Deployment Package easily.

I have created several bundles for my Kura using Maven. For this, I have dedicated a specific folder for all of my Kura Bundles. So whenever I am building those bundles using Maven, I am getting a bundle jar in the target folder of each bundle. Now what I did is to create a General Project to create Deployment Package Definition (DPP) for my bundles. Basically Deployment Package Definition works as similar as Feature Project in Eclipse RCP Application Development.

Suppose I have the following bundles:

com.amitinside.bluecove - which bundles bluecove dependency and exposes javax.bluetooth
com.amitinside.bluecove.fragment - which bundles bluecove gpl fragment
com.amitinside.bluetooth - which bundles bluetooth application to pair devices
com.amitinside.bluetooth.milling.machine - which bundles application to retrieve data from bluetooth enabled devices
com.amitinside.dp.bluetooth - which is a General Project, comprising a Deployment Package Definition for bluecove, fragment and bluetooth bundles
com.amitinside.dp.bluetooth.machine - which is also a General Project, consisting of a Deployment Package Definition for milling machine bundle
com.amitinside.dp.dependencies - another General project for Deployment Package Definition, comprising Guava, Camel, mongo-db, commons-collections which are needed for resolving other bundles

All these afore mentioned projects are kept inside a dedicated folder. Now when I change something in any of my bundles, I build the application first using maven and I right click on my DPP Defition file, export it directly. At the time of export, I don't need to change anything as the DPP knows that the packaged bundle location is in target folder as we have already mentioned that while creating that General Project for Deployment Package Definition.

So, using this method, you don't need not to do menial works, whereas you can configure once and export it whenever you need the updated package. It helps me a lot as it saves me a lot of time.

Just remember to use Maven for creating all of your Kura Bundles and create DPP Projects and configure it to take the package bundles from target folder of your Kura Bundle projects. So, next time onwards, you just build your bundle after you apply your changes and just right click on your DPP file and click on export. That's it. It's simple and easy and moreover, a hassle free Deployment package creation.


Amit Kumar Mondal
Email: admin@amitinside.com
Skype: arsenalnerk Blog: blog.amitinside.com

[Updated on: Fri, 15 May 2015 10:17]

Report message to a moderator

Re: How to create DP package with Maven via command line [message #1696514 is a reply to message #1695496] Tue, 26 May 2015 23:10 Go to previous messageGo to next message
Amit Kumar Mondal is currently offline Amit Kumar MondalFriend
Messages: 108
Registered: March 2015
Location: Munich, Germany
Senior Member

I have found a way to create Deployment Package using Maven.

The project structure what I have discussed above remained same. Now you have to do the following.

1. Right click on the dpp file
2. click on export
3. Under Deployment Package Definition, select Ant Build Script
4. Click on Finish

This will generate 2 files in the project directory
1. The Manifest File
2. Ant Build Script

Now I have created one parent pom project for all of my Deployment Package Definiton which has packaging set to pom and comprises one plugin to execute a shell script.

<plugin>
		<artifactId>exec-maven-plugin</artifactId>
			<groupId>org.codehaus.mojo</groupId>
				<executions>
					<execution>
						<id>Version Calculation</id>
						<phase>generate-sources</phase>
						<goals>
							<goal>exec</goal>
						</goals>
						<configuration>
							<executable>${basedir}/generate-dp.sh</executable>
						</configuration>
					</execution>
				</executions>
		</plugin>


The shell script is as follows:

#!/bin/bash

declare -a arr=("de.tum.in.dp.bluetooth" "de.tum.in.dp.bluetooth.machine" "de.tum.in.dp.cache" "de.tum.in.dp.commons" "de.tum.in.dp.dependencies")
b="_build.xml"
c="/"
home_dir="/Users/AMIT/IoT_IDP/Pi/"

for i in "${arr[@]}"
do
   echo "Generating Deployment Package for $i"
   ant -buildfile  $home_dir$i$c$i$b
done


You can try with maven-ant-run plugin to execute external build scripts.


Amit Kumar Mondal
Email: admin@amitinside.com
Skype: arsenalnerk Blog: blog.amitinside.com
Re: How to create DP package with Maven via command line [message #1696561 is a reply to message #1696514] Wed, 27 May 2015 09:29 Go to previous messageGo to next message
Amit Kumar Mondal is currently offline Amit Kumar MondalFriend
Messages: 108
Registered: March 2015
Location: Munich, Germany
Senior Member

The modified build script with proper comments for better comprehension.

#!/bin/bash

# Declaring all the Deployment Package Project Names to facilitate easy finding of 
# its directory (as the directory name is as same as the project name)

declare -a arr=("de.tum.in.dp.bluetooth" "de.tum.in.dp.bluetooth.machine" "de.tum.in.dp.cache" "de.tum.in.dp.commons" "de.tum.in.dp.dependencies")

# The build file filename extension
b="_build.xml"

# The Directory Separator
c="/"

# The root directory of all the aforementioned projects.
home_dir="/Users/AMIT/IoT_IDP/Pi/"

# The DP file extension
ext=".dp"

# The destination directory to copy all deployment packages
cp_dir="/Users/AMIT/Downloads/"

for i in "${arr[@]}"
do
   echo "Generating Deployment Package for $i"
   
   # Run ant on the build file
   /usr/local/bin/ant -d -buildfile  $home_dir$i$c$i$b
   
   # Move the deployment package to destination folder
   mv $home_dir$i$c$i$ext $cp_dir
done


Amit Kumar Mondal
Email: admin@amitinside.com
Skype: arsenalnerk Blog: blog.amitinside.com
Re: How to create DP package with Maven via command line [message #1701345 is a reply to message #1696561] Sun, 12 July 2015 10:08 Go to previous message
Nirmal Sasidharan is currently offline Nirmal SasidharanFriend
Messages: 9
Registered: May 2014
Junior Member
Deployment package seems to be more or less an obsolete OSGi solution for deployment. Although there are several other solutions like Eclipse P2, Apache KAR etc., all of them are proprietary. OSGi Subsystems in Spec 5 seems to be the standard OSGi way of doing it. Apache Aries provides an implementation for this. I got OSGi Subsystems working with Kura. Deployment for me is now as simple as creating a pom.xml with dependencies I want to deploy, use maven to build a subsystem file and ssh copy it over to a new "deploy" folder I created within Kura (I could have reused the existing "packages" folder. I wanted to intentionally separate them). The deployed plugins are dynamically loaded as soon as it is placed there (either jars or a subsystem file). Also no need to make entries in /opt/eclipse/kura/kura/dpa.properties.

I use the following projects to get it working.


    Apache Aries 1.0.0 (aries.apache.org/modules/subsystems.html) [the latest Aries 2.x will not work as it needs Eclipse 3.10.x. Kura currently is based on 3.8.x]
    Apache File Install (felix.apache.org/documentation/subprojects/apache-felix-file-install.html) to track the new "deploy" folder and install subsystem as soon as a new one is dropped (or updated/deleted). Example: svn.apache.org/repos/asf/aries/trunk/subsystem/subsystem-install/src/main/java/org/apache/aries/subsystem/install/internal/SubsystemInstaller.java
    ESA Maven plugin (aries.apache.org/modules/esamavenpluginproject.html ) to create a subsystem ESA file (similar to DP file)



Helpful hints are available in this blog (coderthoughts.blogspot.de/2013/04/osgi-subsystems.html)

As a newbie with less than 5 messages, the forum doesn't let me add URLs here. Hence incomplete links. I hate spammers!!

[Updated on: Sun, 12 July 2015 10:13]

Report message to a moderator

Previous Topic:My Raspberry Pi is not accessible over network post Kura installation
Next Topic:Lot of exceptions in kura-console.log. Tutorial not working for me
Goto Forum:
  


Current Time: Mon May 13 13:54:27 GMT 2024

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

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

Back to the top