Developers, Developers, Developers! Maksim Sorokin IT Blog


Creating a p2 Repository from Features and Plugins

So you have some features and plugins and you want to publish those to the p2 repository. There is a nice page on describing this procedure.

Here is a recepie.

First, you will need to have to create a folder, which be a source folder for p2 repository. Let's
name it src:

-- src

In this src folder create two other folders called features and plugins:

-- src

Copy your features to features folder and plugins to the plugins folder.
And what you do next is just running

$ECLIPSE -debug -consolelog -nosplash -verbose -application org.eclipse.equinox.p2.publisher.FeaturesAndBundlesPublisher -metadataRepository file:$DEST -artifactRepository file:$DEST -source %SRC% -compress -append -publishArtifacts

where $ECLIPSE is a path to eclipse executable, $DEST is where p2 repository will be created and $SRC is the path to src folder.

That is it.

If you want your plugins be visible on p2 repository, you would need to run additional step. In this case, you would need to create a category.xml file. This file provides information about the categories of your bundles, so they could be seen. If you do not care about nice naming, you can just have a dummy category.xml with which bundles will have category name the same as bundle name:

<?xml version="1.0" encoding="UTF-8"?>
   <category-def name="all" label="Maven osgi-bundles"/>
      <category name="all"/>
      <query><expression type="match">providedCapabilities.exists(p | p.namespace == 'osgi.bundle')</expression></query>

And then run another command:

$ECLIPSE -debug -consolelog -nosplash -verbose -application org.eclipse.equinox.p2.publisher.CategoryPublisher -metadataRepository file:$DEST -categoryDefinition file:PATH_TO/category.xml

Then you can point your eclipse to location of installed p2 repository. If you want to switch feature/bundle view, toggle "Group items by category"

Eclipse, p2, update site

Deployable Feature with Tycho

When building a feature with Tycho, you can define it to be "deployable":


In this case, when Tycho will build it, it will also create a p2 site for this feature including all the plugins and dependencies.

Comments (0) Trackbacks (1)

Leave a comment