Categories
Upload Maven Plugin

Plugin to Publish Eclipse P2 Repositories

I currently work to publish my first RCP application, based on Eclipse/E4 (Kepler). One of the major topics is to automate the complete build and publish process. Tycho does a good job there already, and in fact it works perfect :). I setup my Bamboo instance to build it without any interaction.

However, Tycho does not offer yet any possibility to finally publish P2 repositories. I understand this as publishing can be a difficult job when it comes to various P2 repository flavours (combined, single etc). The Deploy plugin of Maven 3 is not good for this job as far as I have discovered. So I faced the problem of somehow to publish Snapshots and  final releases automatically. The net didn’t come up with any automated solution. Most folks just recommended to perform that step manually.

So I created the Upload Files Maven Plugin. It’s job is to upload any file(s) to the repository valid for an artifact. Users simply define their repositories as they did previously (in <distributionManagement> section of their POM), and then add the plugin to their lifecycle. Here is an example of how to do this.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
   <build>
      <plugins>
         <plugin>
            <groupId>eu.ralph-schuster</groupId>
            <artifactId>uploadfiles-maven-plugin</artifactId>
            <version>1.1.0</version>
            <executions>
               <execution>
                  <goals>
                     <goal>upload</goal>
                  </goals>
                  <phase>deploy</phase>
               </execution>
            </executions>
            <configuration>
               <path>target/repository</path>
               <targetPath>.</targetPath>
            </configuration>
         </plugin>
         ...
      </plugins>
      ...
   </build>

This will upload the P2 repository (created by Tycho) to your defined server repository. As the plugin uses Wagon for this task, you can use protocols such as SCP, FTP, WebDAV etc.

You also might also want to disable default install and deploy targets of Maven for your project:

1
2
3
4
   <properties>
      <maven.install.skip>true</maven.install.skip>
      <maven.deploy.skip>true</maven.deploy.skip>
   </properties>

One nice feature is the execution of pre and post commands on your remote server (tested with SCP only, other protocols might not support this). That can be used e.g. to clean your server repository before uploading the new one:

1
2
3
4
5
6
            <configuration>
               ...
               <preCommands>
                  <preCommand>rm -rf /path/to/repository/*</preCommand>
               </preCommands>
            </configuration>

These commands are executed in the user’s home directory, so please be careful :). There exists several possibilities to handle errors of such commands, so just check out the Goal documentation. It also lists other options you might find useful.

Version 1.1.1 will add a small variable substitution for commands, e.g. you can access the user name and base path of your server repository. This would allow a configuration such as:

1
2
3
4
5
6
            <configuration>
               ...
               <preCommands>
                  <preCommand>rm -rf $repository.basepath/*</preCommand>
               </preCommands>
            </configuration>

However, if you want to use that feature by now, you must use the 1.1.1-SNAPSHOT version. It is not officially released yet as I still want to get more experience with publishing P2 repositories before finally releasing it.

Feedback is welcome…

PS: Maven 3.1.1 is required to use this plugin!
PS: Version 1.1.1 was released meanwhile.