Mirror P2 Repositories with Tycho

Recently I’ve needed the ability to mirror some p2 repositories. In the past, I would setup a new feature, and site.xml/category.xml file to handle this. However, since Tycho 0.13, there is a p2 mirror capability for tycho. It provides the same functionality as the p2.mirror ant task. Setting this up is pretty straight forward.

<properties>
 <tycho-version>0.15.0</tycho-version>
</properties>
<build>
  <plugins>
     <plugin>
         <groupId>org.eclipse.tycho.extras</groupId>
         <artifactId>tycho-p2-extras-plugin</artifactId>
         <version>${tycho-version}</version>
         <executions>
             <execution>
                 <phase>prepare-package</phase>
                 <goals>
                     <goal>mirror</goal>
                 </goals>
             </execution>
         </executions>
         <configuration>
            <source>
	             <repository>
	                <url>http://download.eclipse.org/eclipse/updates/3.7</url>
                   <layout>p2</layout>
	             </repository>
            </source>
	         <destination>${project.build.directory}/repository</destination>
            <compress>true</compress>
         </configuration>
     </plugin>
  </plugins>
</build>

You can include multiple source repositories, and the repository that is created is a combined mirror of both repositories. There is one caveat to using this, if you created your P2 repository and it doesn’t have any features, just plugins, then the process will error out, as it needs features in order to work.

This is extremely useful when you are trying to setup various repositories for testing the installation of new installable features and you don’t have direct access to where the repositories are stored. You can also use this to help stage your repositories say from test, to qa, to production.

Why not just use composite repositories? Mainly because we need stable snapshots of the contents at particular points in times, and also not everybody has direct access to the repository drives. This way allows anybody to clone the repositories and consolidate into one central repository.

Advertisements
This entry was posted in eclipse, p2, tycho. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s