set up your own p2 repository

  1. Prepare a directory of your choice that will contain your plug-ins and features that should be packed into a p2 repository. It can be any directory but needs to contain a folder named plugins and features. E.g.
    p2-source-dir/
    ├── category.xml
    ├── features
    └── plugins
        ├── [..]
        ├── [..]
    
    Place all your plug-ins into the plugins folder, all features into the feature folder. Use this category.xml:
    
    
       
    
            
            
                providedCapabilities.exists(p | p.namespace == 'osgi.bundle')
            
        
    
    
  2. Execute the Features and Bundles Publisher Application which will generate the p2 repository for you:
    java -jar bin/eclipse-rcp-mars/plugins/org.eclipse.equinox.launcher_1.3.100.v20150511-1540.jar -application org.eclipse.equinox.p2.publisher.FeaturesAndBundlesPublisher -metadataRepository file:$repo_target -artifactRepository file:$repo_target -source $repo_source -configs gtk.linux.x86_64 -publishArtifacts
    
  3. Execute the Category Publisher:
    java -jar bin/eclipse-rcp-mars/plugins/org.eclipse.equinox.launcher_1.3.100.v20150511-1540.jar -application org.eclipse.equinox.p2.publisher.CategoryPublisher -metadataRepository file:$repo_target -categoryDefinition file:$category_file_location
    
  4. The generated repository will look like this:
    repository/
    ├── artifacts.xml
    ├── content.xml
    ├── category.xml
    └── plugins
        ├── [..]
        ├── [..]
    └── features
        ├── [..]
        ├── [..]
    
    Done!
    The p2-repository is ready for local use!
  5. As a next step, you can copy the repository to a location accessible via HTTP, as a Tycho build e.g. is not able to use a local p2 repository (See here).
  6. If you are developing some libraries using maven and would like to put them to your p2-repository as well, you can prepare them as described here.
  7. If you would like to use some third-party libs, such as apache-commons, you can convert them into OSGi/ p2 compatible plug-ins and publish them into another p2-repository using the p2-maven-plugin.
Share itShare on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

Leave a Reply

Your email address will not be published. Required fields are marked *