I try to use my legacy code in my Eclipe-RCP Application. I took all my old maven projects with dependencies and used the maven-bundle-plugin to create an osgi bundle.
Now i have everything wrapped up in a new osgi jar.
How to create a p2 update site from this OSGi jar to use with Tycho and the Eclipse target platform?
I tried: https://docs.sonatype.org/display/TYCHO/How+to+make+existing+OSGi+bundles+consumable+by+Tycho (see web archive)
Publishing a P2 Repository
Prerequisites:
- Local Eclipse Galileo installation in %ECLIPSE_HOME% We want to generate P2 metadata for a bunch of OSGi bundles which we have locally in the filesystem. Eclipse provides the FeaturesAndBundlesPublisher command line application for this task.
- First of all we copy all bundle jars into a <BUNDLE_ROOT>/plugins directory
- Then we execute
%ECLIPSE_HOME%\eclipsec.exe -debug -consolelog -nosplash -verbose -application org.eclipse.equinox.p2.publisher.FeaturesAndBundlesPublisher -metadataRepository file:/<BUNDLE_ROOT>/repo -artifactRepository file:<BUNDLE_ROOT>/repo -source <BUNDLE_ROOT> -compress -publishArtifacts
- The result is a P2 repository with all OSGi bundles under <BUNDLE_ROOT>/repo. Note the generated P2 metadata files artifacts.jar and content.jar in the repo directory.
Making the New P2 Repository Available via HTTP
The P2 repository in <BUNDLE_ROOT>/repo is complete, we just need to make it available via HTTP so it can be globally referenced.
This could be done using any HTTP server such as Apache. In our case we chose to deploy it on Tomcat as we already have a tomcat running for other purposes such as Hudson etc.
On the host running tomcat, copy the contents of <BUNDLE_ROOT>/repo to <TOMCAT_HOME>/webapps/<YOUR_REPO_DIR>
From now on you could reference this P2 repository in pom.xml as
<repository> <id>tomcat-p2</id> <layout>p2</layout> <url>http://<TOMCAT_HOST>:<TOMCAT_PORT>/<YOUR_REPO_DIR></url> </repository>
If i put the resulting files on a web server eclipse is not recognizing it as "Software Site".
How to create a p2 Software Site from existing osgi bundles without using the Eclipse UI, the process has to run in background on my build-server.
Is there a way to use Maven (Tycho)/ Gradle to automatically create a p2 update site from an existing osgi bundle?
I always use these two commands to generate a p2 repository:
java -jar %ECLIPSE_HOME%\plugins\org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar -application org.eclipse.equinox.p2.publisher.FeaturesAndBundlesPublisher -metadataRepository file:/C:/repository -artifactRepository file:/C:/destination -source /C:/source -configs gtk.linux.x86 -compress -publishArtifacts
where c:/source
are stored my bundles, and then
%ECLIPSE_HOME%/eclipse -debug -consolelog -nosplash -verbose -application org.eclipse.equinox.p2.publisher.CategoryPublisher -metadataRepository file:C:/destination -categoryDefinition file:C:/source/category.xml
the C:/source
tree is like this
source
-- feaures
-- plugins
-- category.xml
and you'll need this category.xml
file to group your bundles into categories. This is the category's content
<?xml version="1.0" encoding="UTF-8"?>
<site>
<category-def name="all" label="P2 Repo"/>
<iu>
<category name="all"/>
<query><expression type="match">providedCapabilities.exists(p | p.namespace == 'osgi.bundle')</expression></query>
</iu>
</site>
depending on your eclipse version, maybe you'll need to change the version of this file org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar