Developing Plug-Ins - Create a Feature-Project to export Plug-Ins and Fragments

From iDempiere en
Jump to navigation Jump to search

This tutorial is brought to you by Jan Thielemann from evenos GmbH (www.evenos-consulting.de). If you have questions, criticism or improvement suggestions, feel free to visit me (Jan.thielemann) or write me an email

Goal of this tutorial

The goal of this tutorial is to show, how you can create an OSGi Feature-Project to export multiple plug-ins and fragments into one p2 repository and then install the whole feature group on the server.

Prerequisites

To follow this tutorial, you preferably already have some plug-ins and/or fragments you want to export. Otherwise, take a look at Plug-In Development Guide and create some plug-ins first.

The workflow

Create a new feature

Start by creating a new Feature-Project. Go to File>New>Other and select Feature-Project from the Plug-in Development section.

Featureproject1.png


Chose a name and a location for this feature and on finish.

Featureproject2.png

Configure the feature.xml

Open the feature.xml and switch to the Plug-ins tab. Add the plug-ins and fragments you want to export within this feature.

Featureproject3.png


You can also include other feature projects but we won't do that in this tutorial. The next step is to switch to the Dependencies tab and click on compute to compute the dependencies which the selected plug-ins and fragments come with.

Featureproject4.png

Export the feature using the Export Wizard

Switch back to the Overview tab of the feature.xml. Find and click the Export Wizard. It is a blue, underlined button in the Exporting section. Select a directory to where the wizard should export the feature.

Featureproject5.png


Switch to the options tab and check the boxes as shown below

Featureproject6.png

(remark from User:TBayen: I had to set os, window toolkit & architecture in the Eclipse Platform settings to make this work)

You now should have a ready to use p2 repository which should look similar to this structure:

Featureproject7.png

Install a feature on the server using the director

Go to your idempiere servers home directory. Here you find the update.sh which can be modified a little bit so you can use it to install/uninstall features. You can use the following code to create a simple to use script:

#!/bin/sh
#

cd $(dirname "${0}")
DESTINATION=$(pwd)

cp idempiere.ini idempiere.ini.sav

java -Dosgi.noShutdown=false -Dosgi.compatibility.bootdelegation=true -Dosgi.install.area=director -jar plugins/org.eclipse.osgi_3.7.*.jar -application org.eclipse.equinox.p2.director -consoleLog -profileProperties org.eclipse.update.install.features=true -destination $DESTINATION -repository $1 -u $2


java -Dosgi.noShutdown=false -Dosgi.compatibility.bootdelegation=true -Dosgi.install.area=director -jar plugins/org.eclipse.osgi_3.7.*.jar -application org.eclipse.equinox.p2.director -consoleLog -profileProperties org.eclipse.update.install.features=true -destination $DESTINATION -repository $1 -i $2


cp idempiere.ini.sav idempiere.ini

Save the code in a file like "updateInstallFeatures.sh". You can now use this script from within the server home directory to install features. Simply call

./updateInstallFeatures.sh file:/path/to/p2/repository org.domain.myfeature.feature.group

The first parameter is the path or the url to the p2 repository which you exportet before. The second parameter is the id of the feature project (you specified it in the feature.xml) followed by ".feature.group". The eclipse director will now uninstall the given feature and install the newest available version in your p2 repository.

Check the content of a p2 repository

Before you un-/install something, you can check the content of a p2 repository by running the following line from within your idempiere server home directory:

java -Dosgi.noShutdown=false -Dosgi.compatibility.bootdelegation=true -Dosgi.install.area=director -jar plugins/org.eclipse.osgi_3.7.*.jar -application org.eclipse.equinox.p2.director -consoleLog -repository file:/path/to/my/feature/p2 -list

Check installation

To check if the feature was installed, you can run the following command from within your idempiere server home directory:

java -Dosgi.noShutdown=false -Dosgi.compatibility.bootdelegation=true -Dosgi.install.area=director -jar plugins/org.eclipse.osgi_3.7.*.jar -application org.eclipse.equinox.p2.director -consoleLog -lir