Create local p2 site from remote p2 sites?

1.5k views Asked by At

In eclipse I have created a .target file where I add features from remote eclipse p2 sites.

Now I would like to create a local p2 site which is a copy of the aggregated features defined in the target definition (and preferably for all environments).

I need this local p2 site to be used with a build system using maven3/tycho but have not found a "stable" way to do this. I have tried the following:

1) Export the target file to local directory.

Problem: Does not create a p2 site just a folder with features/plugins.

2) Export the target file to local directory AND run the eclipse FeaturesAndBundlesPublisher application on the directory.

Problem: This creates a p2 site but some of the original features/bundles are missing.

3) Used buckmeister to create a p2 site from a feature initialized from a .target file:

p2.site using buckmeister

Problem: The original features from the content of the .target file are not preserved in the resulting p2 site. Especially this is a problem if the target file contains the feature: org.eclipse.equinox.executable.feature this feature will be missing in the resulting p2 site.

4) Copy the content of:

workspace.metadata.plugins\org.eclipse.pde.core.bundle_pool

Problem: Is not a valid p2 site.

Any suggestion on how to create a working (with intact features) local p2 site from remote p2 sites?

2

There are 2 answers

2
Konstantin Komissarchik On

You want to use p2 mirror command. Give it a remote repository URL and a local directory to mirror to. Here is an Ant macro to do this. Note how it's making two mirror calls as most p2 repositories are actually two repositories in one (artifacts and metadata).

It needs "bootstrap.platform" property set which is a location of Eclipse install whose p2 you want to use.

  <macrodef name="p2.mirror">
    <attribute name="source"/>
    <attribute name="destination"/>
    <sequential>
      <echo message="Mirroring repository @{source} to @{destination}..."/>
      <java classname="org.eclipse.core.launcher.Main" fork="true" failonerror="true">
        <classpath>
          <fileset dir="${bootstrap.platform}/plugins">
            <include name="**/org.eclipse.equinox.launcher_*.jar"/>
          </fileset>
        </classpath>
        <arg line="-application org.eclipse.equinox.p2.artifact.repository.mirrorApplication"/>
        <arg line="-source @{source}"/>
        <arg line="-destination @{destination}"/>
      </java>
      <java classname="org.eclipse.core.launcher.Main" fork="true" failonerror="true">
        <classpath>
          <fileset dir="${bootstrap.platform}/plugins">
            <include name="**/org.eclipse.equinox.launcher_*.jar"/>
          </fileset>
        </classpath>
        <arg line="-application org.eclipse.equinox.p2.metadata.repository.mirrorApplication"/>
        <arg line="-source @{source}"/>
        <arg line="-destination @{destination}"/>
      </java>
    </sequential>
  </macrodef>
0
mkdev On

Instead of using Ant you can run it directly from command line:

eclipse -nosplash -verbose
  -application org.eclipse.equinox.p2.artifact.repository.mirrorApplication
  -source http://download.eclipse.org/releases/luna
  -destination file:/temp/lunaclone

eclipse -nosplash -verbose
  -application org.eclipse.equinox.p2.metadata.repository.mirrorApplication
  -source http://download.eclipse.org/releases/luna
  -destination file:/temp/lunaclone

Each command should be of course one line when entering.

If your a using a windows system the destination path would be like

  -destination file:C:/temp/lunaclone

If your need a different version (-source) than have a look at Eclipse Project Update Sites