title: How to create a p2 repository from an existing osgi bundle?
body: <p>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.</p>
  <p>Now i have everything wrapped up in a new osgi jar.</p>
  <p>How to create a p2 update site from this OSGi jar to use with Tycho and the Eclipse target platform?</p>
  <p>I tried: <a href="https://docs.sonatype.org/display/TYCHO/How+to+make+existing+OSGi+bundles+consumable+by+Tycho" rel="nofollow noreferrer">https://docs.sonatype.org/display/TYCHO/How+to+make+existing+OSGi+bundles+consumable+by+Tycho</a> (see <a href="https://web.archive.org/web/20140530081029/https://docs.sonatype.org/display/TYCHO/How+to+make+existing+OSGi+bundles+consumable+by+Tycho" rel="nofollow noreferrer">web archive</a>)</p>
  <blockquote>
  <h2>Publishing a P2 Repository</h2>
  <p>Prerequisites:</p>
  <ul>
  <li>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 <a href="https://web.archive.org/web/20140530081029/http://wiki.eclipse.org/Equinox/p2/Publisher#Features_And_Bundles_Publisher_Application" rel="nofollow noreferrer">FeaturesAndBundlesPublisher command line application</a> for this task.</li>
  </ul>
  <ol>
  <li>First of all we copy all bundle jars into a &lt;BUNDLE_ROOT&gt;/plugins directory</li>
  <li>Then we execute</li>
  </ol>
  <pre><code>  %ECLIPSE_HOME%\eclipsec.exe -debug -consolelog -nosplash -verbose -application
          org.eclipse.equinox.p2.publisher.FeaturesAndBundlesPublisher
          -metadataRepository file:/&lt;BUNDLE_ROOT&gt;/repo
          -artifactRepository file:&lt;BUNDLE_ROOT&gt;/repo
          -source &lt;BUNDLE_ROOT&gt; -compress -publishArtifacts
  </code></pre>
  <ol start="3">
  <li>The result is a P2 repository with all OSGi bundles under &lt;BUNDLE_ROOT&gt;/repo. Note the generated P2 metadata files artifacts.jar and content.jar in the repo directory.</li>
  </ol>
  <h2>Making the New P2 Repository Available via HTTP</h2>
  <p>The P2 repository in &lt;BUNDLE_ROOT&gt;/repo is complete, we just need to make it available via HTTP so it can be globally referenced.</p>
  <p>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.</p>
  <p>On the host running tomcat, copy the contents of &lt;BUNDLE_ROOT&gt;/repo to &lt;TOMCAT_HOME&gt;/webapps/&lt;YOUR_REPO_DIR&gt;</p>
  <p>From now on you could reference this P2 repository in pom.xml as</p>
  <pre><code>&lt;repository&gt;
    &lt;id&gt;tomcat-p2&lt;/id&gt;
    &lt;layout&gt;p2&lt;/layout&gt;
    &lt;url&gt;http://&lt;TOMCAT_HOST&gt;:&lt;TOMCAT_PORT&gt;/&lt;YOUR_REPO_DIR&gt;&lt;/url&gt;
  &lt;/repository&gt;
  </code></pre>
  </blockquote>
  <p>If i put the resulting files on a web server eclipse is not recognizing it as &quot;Software Site&quot;.</p>
  <p>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.</p>
  <p>Is there a way to use Maven (Tycho)/ Gradle to automatically create a p2 update site from an existing osgi bundle?</p>