SKM IT World

Just another blog about IT


1 Comment

Generate P2 Repository From Maven Dependencies

Motivation

If you use Maven Tycho to build your Eclipse RCP application, you can use Maven dependencies as you know it from Maven (for more information see [1]). I notice that Tycho takes many times for computing the target platform from the Maven dependencies during the build. I expect a speed up of build time if I use a P2 repository instead of Maven dependencies directly. Therefore, the task is how do I get the Maven dependencies to a P2 repository.

Procedure for generating a P2 repository from Maven dependencies

We generate the P2 repository with the help of some Maven’s plugin and some Maven Tycho’s plugin:

  • Builder Helper Maven Plugin
  • Maven Dependency Plugin
  • Maven Tycho’s P2 Extra Plugin
  • Maven Tycho’s P2 Plugin
  • Maven Tycho’s P2 Repository Plugin

Maven Tycho’s Plugins use Eclipse standard tools internally. How the Eclipse standard tools work are described well on this blog post [2]. Further useful information about Tycho’s plugins can be found in [3] and [4].

We create a POM project and configure plugins mentioned above, so that the following procedure can work:

  1. Define the Maven dependencies, that should be add to the P2 repository, in the <dependencies> section.
  2. Copy these defined dependencies to the source location of the Feature and Bundle Publisher with Maven Dependency Plugin.
  3. Generate P2 repository with P2 Extra Plugin.
  4. Add categories to the P2 metadata with P2 Plugin, so that you can see your P2 repository in Eclipse Target Platform Wizard.
  5. Zip P2 repository with P2 Repository Plugin.
  6. Attach zipped P2 repository to be installed and deployed in the Maven repository during the deploy phase with Builder Helper Plugin.

You can find the whole POM configuration in [5].

How to use zipped P2 Repository from Maven Repository

When you use Nexus as Maven Repository, you can use the Nexus Unzip Plugin ([6]).

Links

[1] Maven Tycho How to – Dependency on pom-first artifacts
[2] Blog Post about Generation P2 Repository with Eclipse Standard Tool
[3] P2 Extra Plugin Project Site
[4] Sonatype Wiki Page about P2 Extra Plugin
[5] POM Project on GitHub
[6] Nexus Unzip Plugin Documentation


2 Comments

Set up a Proxy P2 Repository with Nexus OOS

Assumption

I assume Nexus OOS in version 2.1.2 is installed. You can find a good tutorial in Sonatype’s Nexus book Repository Management with Nexus (Chapter 3: Installing and Running Nexus).

Preparation

For the set up of a proy P2 repository three Nexus plugins are needed:

  • Nexus Capability Plugin (It is contained¬† in the basic Nexus installation)
  • Nexus P2 Bridge Plugin 2.0.5 (Download)
  • Nexus P2 Repository Plugin 2.2¬† (Download)

It is important that you download the artifacts ending with -bundle.zip. Unzip both plugins in the directory $NEXUS_HOME/../sonatype-work/nexus/plugin-repository of your Nexus instance. Restart your Nexus instance. Then follow the instruction for creating a proxy P2 repository in the Sonatype Nexus book.

Troubleshooting

After I had created two proxy P2 Repositories, Nexus ran unstable. It restarted every night, automatically. A post in Nexus Mailing List advised me to increasing the heap space to 1024MB for a stable run with proxies P2 Repository:

  1. Open the config file $NEXUS_HOME/nexus/bin/jsw/conf/wrapper.conf.
  2. Edit the property wrapper.java.maxmemory.

Increasing the heap space to 1024MV solves my problem.

Links