Back to top

vogella training Training Books

Eclipse Tycho - Tutorial for building Eclipse Plugins and RCP applications

Lars Vogel

Version 1.3

15.03.2013

Revision History
Revision 0.1 07.08.2011 Lars
Vogel
created
Revision 0.2 - 1.3 15.03.2013 Lars
Vogel
bug fixes and enhancements

Eclipse Tycho

This tutorial describes how to use Eclipse Tycho to build Eclipse Plug-ins and Eclipse RCP applications

This tutorials is based on Eclipse 4.2 and Java 1.6.


Table of Contents

1. Build tools
2. Apache Maven
3. Tycho
3.1. Tycho Overview
3.2. pom.xml configuration files
3.3. Source Encoding
3.4. Package attribute
3.5. Target Platform
3.6. Eclipse Maven Integration
3.7. Generating pom files via Tycho
4. Pre-requirements
5. Installation
5.1. Maven command line
5.2. m2eclipse plug-in installation
6. Tutorial: Building Eclipse components
6.1. Overview
6.2. Create master project for the build
6.3. Create projects to build
6.4. Create pom for plug-in project
6.5. Create pom for feature
6.6. Create pom for p2 update site
6.7. Building
7. Building Eclipse products
8. Automatic deployment
9. Thank you
10. Questions and Discussion
11. Links and Literature
11.1. Source Code
11.2. Maven Tycho Resources

1. Build tools

A build tool is used to automate repetitive tasks. This can be for example compiling source code, running software tests and creating files and documentation for the software deployment.

Build tools typically run without a graphical user interface (headless) directly from the command line.

Popular build tools in the Java space are Apache Ant, Maven and Gradle.

2. Apache Maven

Apache Maven is a build tool, e.g. it compiles source code and packages the result in a usable form.

Maven projects are defined via pom.xml (Project Object Model) files.

Maven supports archetypes. In Maven, an archetype is a template of a project which is combined with some user input to produce a working Maven project that has been tailored to the user's requirements.

If you run a Maven build it downloads all dependencies into a local Maven repository which is by default in the users home directory and is called .m2/repository. Maven only downloads the dependencies if they have changed.

Maven builds into the local target folder and creates the build result in this folder. If you run the mvn install command, Maven compiles the source code, builds the result, e.g. the jar file and install the build result into the local .m2/repository repository.

# default to run Maven
# compiles, build and install the build result
maven install 

# Forces an update of the dependencies
maven -U install 

# deletes the target folder of the project
# and runs again the install
# but re-uses dependencies
maven clean install 

The mvn install command also installs the build result into the local .m2/repository repository. If you want to clean this repository you can delete this repository. This triggers Maven to download all dependencies again.

By default, Maven checks if the dependencies have been changed. If you want to use your local repository you can use the -o to tell Maven to work offline.

# work offline , i.e. use the local maven repository
maven -o clean install 

3. Tycho

3.1. Tycho Overview

Eclipse Tycho provides Maven support for building Eclipse components. Tycho is a set of Maven plug-ins.

Tycho supports the creation of Eclipse Plug-ins, Eclipse features, Eclipse update sites (based on p2) and building of Eclipse products.

Tycho uses the metadata of the Eclipse components in the MANIFEST.MF file as much as possible. This leads to relative small pom.xml configuration files.

The Tycho plug-ins are automatically installed into Maven based on the pom.xml configuration files you provide.

3.2. pom.xml configuration files

The configuration for a Maven or Tycho build is stored in files called pom.xml. To build Eclipse components you typically create a master configuration file which includes the Tycho plug-ins and the definition of the build environment. Within this master configuration file you include all Eclipse components which should be built as modules.

This module definition in your master pom.xml file could for example look like the following.

<modules>
  <module>de.vogella.tycho.plugin</module>
  <module>de.vogella.tycho.plugin2</module>
  <module>de.vogella.tycho.feature</module>
</modules> 

A typical master pom.xml file looks like the following.

<?xml version="1.0" encoding="UTF-8"?>
<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.vogella</groupId>
  <artifactId>parent</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <packaging>pom</packaging>
  <modules>
    <module>../de.vogella.tycho.plugin</module>
    <module>../de.vogella.tycho.feature</module>
    <module>../de.vogella.tycho.p2updatesite</module>
  </modules>

  <properties>
    <tycho.version>0.16.0</tycho.version>
    <tycho-extras.version>0.16.0</tycho-extras.version>

    <juno-repo.url>http://download.eclipse.org/releases/juno</juno-repo.url>
    <tycho-repo.url>https://oss.sonatype.org/content/groups/public/</tycho-repo.url>
  </properties>


  <repositories>
    <repository>
      <id>juno</id>
      <url>${juno-repo.url}</url>
      <layout>p2</layout>
    </repository>

  </repositories>

  <pluginRepositories>
    <pluginRepository>
      <id>tycho</id>
      <url>${tycho-repo.url}</url>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </pluginRepository>
  </pluginRepositories>

  <build>
    <plugins>
      <plugin>
        <groupId>org.eclipse.tycho</groupId>
        <artifactId>tycho-maven-plugin</artifactId>
        <version>${tycho.version}</version>
        <extensions>true</extensions>
      </plugin>

      <plugin>
        <groupId>org.eclipse.tycho</groupId>
        <artifactId>target-platform-configuration</artifactId>
        <configuration>
          <environments>
            <environment>
              <os>linux</os>
              <ws>gtk</ws>
              <arch>x86</arch>
            </environment>
            <environment>
              <os>linux</os>
              <ws>gtk</ws>
              <arch>x86_64</arch>
            </environment>
            <environment>
              <os>win32</os>
              <ws>win32</ws>
              <arch>x86</arch>
            </environment>
            <environment>
              <os>win32</os>
              <ws>win32</ws>
              <arch>x86_64</arch>
            </environment>
            <environment>
              <os>macosx</os>
              <ws>cocoa</ws>
              <arch>x86_64</arch>
            </environment>
          </environments>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.eclipse.tycho</groupId>
        <artifactId>tycho-source-plugin</artifactId>
        <executions>
          <execution>
            <id>plugin-source</id>
            <goals>
              <goal>plugin-source</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>

    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.eclipse.tycho</groupId>
          <artifactId>target-platform-configuration</artifactId>
          <version>${tycho.version}</version>
        </plugin>
        <plugin>
          <groupId>org.eclipse.tycho</groupId>
          <artifactId>tycho-compiler-plugin</artifactId>
          <version>${tycho.version}</version>
          <configuration>
            <compilerArguments>
              <inlineJSR />
              <enableJavadoc />
              <encoding>ISO-8859-1</encoding>
            </compilerArguments>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.eclipse.tycho</groupId>
          <artifactId>tycho-packaging-plugin</artifactId>
          <version>${tycho.version}</version>
          <dependencies>
            <dependency>
              <groupId>org.eclipse.tycho.extras</groupId>
              <artifactId>tycho-buildtimestamp-jgit</artifactId>
              <version>${tycho-extras.version}</version>
            </dependency>
          </dependencies>
          <configuration>
            <strictBinIncludes>false</strictBinIncludes>
            <format>'v'yyyyMMdd-HHmm</format>
            <timestampProvider>jgit</timestampProvider>
            <jgit.ignore>
            </jgit.ignore>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.eclipse.tycho</groupId>
          <artifactId>tycho-surefire-plugin</artifactId>
          <version>${tycho.version}</version>
        </plugin>
        <plugin>
          <groupId>org.eclipse.tycho</groupId>
          <artifactId>tycho-source-plugin</artifactId>
          <version>${tycho.version}</version>
          <configuration>
            <strictSrcIncludes>false</strictSrcIncludes>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.eclipse.tycho</groupId>
          <artifactId>tycho-p2-director-plugin</artifactId>
          <version>${tycho.version}</version>
        </plugin>
        <plugin>
          <groupId>org.eclipse.tycho</groupId>
          <artifactId>tycho-p2-repository-plugin</artifactId>
          <version>${tycho.version}</version>
        </plugin>
        <plugin>
          <groupId>org.eclipse.tycho.extras</groupId>
          <artifactId>tycho-source-feature-plugin</artifactId>
          <version>${tycho-extras.version}</version>
        </plugin>
        <plugin>
          <groupId>org.eclipse.tycho.extras</groupId>
          <artifactId>tycho-custom-bundle-plugin</artifactId>
          <version>${tycho-extras.version}</version>
        </plugin>
        <plugin>
          <groupId>org.eclipse.tycho</groupId>
          <artifactId>tycho-p2-plugin</artifactId>
          <version>${tycho.version}</version>
          <configuration>
            <baselineMode>warn</baselineMode>
            <baselineReplace>none</baselineReplace>
            <baselineRepositories>
              <repository>
                <url>http://download.eclipse.org/eclipse/updates/4.2</url>
              </repository>
            </baselineRepositories>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

</project> 

Each module has again a pom.xml configuration file which defines attributes specifically to the corresponding Eclipse component, e.g. the package attribute. The pom.xml files of the modules refer to their parent pom.xml file.

3.3. Source Encoding

You can set the source code encoding via the project.build.sourceEncoding parameter.

<properties>
 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> 

3.4. Package attribute

The package attribute defines which Eclipse components should be created by Tycho.

Table 1. Package Attribute

Package Attribute Description
eclipse-plugin Used for Plug-ins
eclipse-feature Used for features
eclipse-repository Used for p2 update sites and Eclipse products

After setting up your pom.xml configuration files, you can build your Eclipse components with following commands.

# Switch to the directory 
# of you master build file
cd your_master_build_dir

# Commands to build
mvn clean
mvn compile
mvn install

# Alternatively use the following
mvn clean install

# To get debug output use the -X flag
mvn clean install -X 

3.5. Target Platform

The target platform is the set of artifacts from which Tycho resolves the project's dependencies. You can either use a target definition based on the Eclipse p2 update manager or on Target Definition files.

The following description uses p2 repositories, for a setup using Target Definition files please check the links at the end of this tutorial.

3.6. Eclipse Maven Integration

Maven provides also a plug-in which integrates Maven into the Eclipse IDE. The installation and usage of this plug-in is not described as this tutorial uses the Maven built from the command line.

3.7. Generating pom files via Tycho

Tycho allows to created default pom.xml configuration files. You can use the following command to generate default files. The -DgroupId allows you to specify the group ID for the pom files.

# Group ID is set to com.vogella.tycho.build 
mvn org.eclipse.tycho:tycho-pomgenerator-plugin:generate-poms \
  -DgroupId=com.vogella.tycho.build 

This will generate a pom for all modules below the current directory and a parent pom in the current directory. IF you want to include Eclipse components which are not in the current directory you can point Tycho to these directories via the -DextraDirs parameter.

mvn org.eclipse.tycho:tycho-pomgenerator-plugin:generate-poms \
 -DgroupId=com.vogella.tycho.build -DextraDirs="../../another_plugin_dir 

You can also update existing pom files with the latest version number via the following command.

# update pom files
mvn org.eclipse.tycho:tycho-versions-plugin:update-pom 
  -Dtycho.mode=maven 

4. Pre-requirements

The following assumes that you are familiar with Eclipse plug-in and RCP development, e.g. the creation of plug-ins, features and products. Check Eclipse Plug-in Tutorial and Eclipse RCP Tutorial . Also see Eclipse Feature Project to learn how to create feature projects.

5. Installation

5.1. Maven command line

The installation of Maven is described on the following website. You need to install Maven3.

http://maven.apache.org/download.html#Installation 

5.2. m2eclipse plug-in installation

You can also install the Maven Eclipse tooling. Install the m2eclipse plug-in into Eclipse via the following update site.

http://download.eclipse.org/technology/m2e/releases 

6. Tutorial: Building Eclipse components

6.1. Overview

The following description demonstrates how to build Eclipse plug-ins, feature and how to create Eclipse p2 update sites with Maven Tycho.

This tutorial is a stand-alone description for building Eclipse plug-ins and features, e.g. all required Eclipse components are created in this tutorial.

6.2. Create master project for the build

Create a new project of type General called de.vogella.tycho.master. This project will contain the master pom.xml for building the plug-ins.

Create the following pom.xml file in the de.vogella.tycho.master project.

<?xml version="1.0" encoding="UTF-8"?>
<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.vogella</groupId>
  <artifactId>parent</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <packaging>pom</packaging>
  <modules>
    <module>../de.vogella.tycho.plugin</module>
    <module>../de.vogella.tycho.feature</module>
    <module>../de.vogella.tycho.p2updatesite</module>
  </modules>

  <properties>
    <tycho.version>0.16.0</tycho.version>
    <tycho-extras.version>0.16.0</tycho-extras.version>

    <juno-repo.url>http://download.eclipse.org/releases/juno</juno-repo.url>
    <tycho-repo.url>https://oss.sonatype.org/content/groups/public/</tycho-repo.url>
  </properties>


  <repositories>
    <repository>
      <id>juno</id>
      <url>${juno-repo.url}</url>
      <layout>p2</layout>
    </repository>

  </repositories>

  <pluginRepositories>
    <pluginRepository>
      <id>tycho</id>
      <url>${tycho-repo.url}</url>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </pluginRepository>
  </pluginRepositories>

  <build>
    <plugins>
      <plugin>
        <groupId>org.eclipse.tycho</groupId>
        <artifactId>tycho-maven-plugin</artifactId>
        <version>${tycho.version}</version>
        <extensions>true</extensions>
      </plugin>

      <plugin>
        <groupId>org.eclipse.tycho</groupId>
        <artifactId>target-platform-configuration</artifactId>
        <configuration>
          <environments>
            <environment>
              <os>linux</os>
              <ws>gtk</ws>
              <arch>x86</arch>
            </environment>
            <environment>
              <os>linux</os>
              <ws>gtk</ws>
              <arch>x86_64</arch>
            </environment>
            <environment>
              <os>win32</os>
              <ws>win32</ws>
              <arch>x86</arch>
            </environment>
            <environment>
              <os>win32</os>
              <ws>win32</ws>
              <arch>x86_64</arch>
            </environment>
            <environment>
              <os>macosx</os>
              <ws>cocoa</ws>
              <arch>x86_64</arch>
            </environment>
          </environments>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.eclipse.tycho</groupId>
        <artifactId>tycho-source-plugin</artifactId>
        <executions>
          <execution>
            <id>plugin-source</id>
            <goals>
              <goal>plugin-source</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>

    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.eclipse.tycho</groupId>
          <artifactId>target-platform-configuration</artifactId>
          <version>${tycho.version}</version>
        </plugin>
        <plugin>
          <groupId>org.eclipse.tycho</groupId>
          <artifactId>tycho-compiler-plugin</artifactId>
          <version>${tycho.version}</version>
          <configuration>
            <compilerArguments>
              <inlineJSR />
              <enableJavadoc />
              <encoding>ISO-8859-1</encoding>
            </compilerArguments>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.eclipse.tycho</groupId>
          <artifactId>tycho-packaging-plugin</artifactId>
          <version>${tycho.version}</version>
          <dependencies>
            <dependency>
              <groupId>org.eclipse.tycho.extras</groupId>
              <artifactId>tycho-buildtimestamp-jgit</artifactId>
              <version>${tycho-extras.version}</version>
            </dependency>
          </dependencies>
          <configuration>
            <strictBinIncludes>false</strictBinIncludes>
            <format>'v'yyyyMMdd-HHmm</format>
            <timestampProvider>jgit</timestampProvider>
            <jgit.ignore>
            </jgit.ignore>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.eclipse.tycho</groupId>
          <artifactId>tycho-surefire-plugin</artifactId>
          <version>${tycho.version}</version>
        </plugin>
        <plugin>
          <groupId>org.eclipse.tycho</groupId>
          <artifactId>tycho-source-plugin</artifactId>
          <version>${tycho.version}</version>
          <configuration>
            <strictSrcIncludes>false</strictSrcIncludes>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.eclipse.tycho</groupId>
          <artifactId>tycho-p2-director-plugin</artifactId>
          <version>${tycho.version}</version>
        </plugin>
        <plugin>
          <groupId>org.eclipse.tycho</groupId>
          <artifactId>tycho-p2-repository-plugin</artifactId>
          <version>${tycho.version}</version>
        </plugin>
        <plugin>
          <groupId>org.eclipse.tycho.extras</groupId>
          <artifactId>tycho-source-feature-plugin</artifactId>
          <version>${tycho-extras.version}</version>
        </plugin>
        <plugin>
          <groupId>org.eclipse.tycho.extras</groupId>
          <artifactId>tycho-custom-bundle-plugin</artifactId>
          <version>${tycho-extras.version}</version>
        </plugin>
        <plugin>
          <groupId>org.eclipse.tycho</groupId>
          <artifactId>tycho-p2-plugin</artifactId>
          <version>${tycho.version}</version>
          <configuration>
            <baselineMode>warn</baselineMode>
            <baselineReplace>none</baselineReplace>
            <baselineRepositories>
              <repository>
                <url>http://download.eclipse.org/eclipse/updates/4.2</url>
              </repository>
            </baselineRepositories>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

</project> 

6.3. Create projects to build

Create a new plug-in project called de.vogella.tycho.plugin.

Create a new feature project called de.vogella.tycho.feature which includes the de.vogella.tycho.plugin plug-in.

Create a new project of type General called de.vogella.tycho.p2updatesite. Select the main folder of this project and select FileNewOther...Plug-in DevelopmentCategory Definition. Create a new category and include your feature project.

6.4. Create pom for plug-in project

Create the pom.xml file for the de.vogella.tycho.plugin project.

<?xml version="1.0" encoding="UTF-8"?>
<project>
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <relativePath>../de.vogella.tycho.master/pom.xml</relativePath>
    <groupId>com.vogella</groupId>
    <artifactId>parent</artifactId>
    <version>1.0.0-SNAPSHOT</version>
  </parent>

  <artifactId>de.vogella.tycho.plugin</artifactId>
  <packaging>eclipse-plugin</packaging>
</project> 

6.5. Create pom for feature

Create the following pom.xml file for the de.vogella.tycho.feature project.

<?xml version="1.0" encoding="UTF-8"?>
<project>
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <relativePath>../de.vogella.tycho.master/pom.xml</relativePath>
    <groupId>com.vogella</groupId>
    <artifactId>parent</artifactId>
    <version>1.0.0-SNAPSHOT</version>
  </parent>

  <artifactId>de.vogella.tycho.feature</artifactId>
  <packaging>eclipse-feature</packaging>

</project> 

6.6. Create pom for p2 update site

Create the following pom.xml file for de.vogella.tycho.p2update project.

<?xml version="1.0" encoding="UTF-8"?>
<project>
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <relativePath>../de.vogella.tycho.master/pom.xml</relativePath>
    <groupId>com.vogella</groupId>
    <artifactId>parent</artifactId>
    <version>1.0.0-SNAPSHOT</version>
  </parent>

  <artifactId>de.vogella.tycho.p2updatesite</artifactId>
  <packaging>eclipse-repository</packaging>

</project> 

6.7. Building

Switch to the directory of your master plug-in and type the following commands to build your components.

# Switch to the directory 
# of you master build file
cd your_master_build_dir

# Commands to build
mvn clean
mvn compile
mvn install

# Alternatively use the following
mvn clean install

# To get debug output use the -X flag
mvn clean install -X 

7. Building Eclipse products

You can also use Tycho to build Eclipse based products.

For the purpose of a product build, you should create a separate project for your product configuration file. To build your product with Tycho you need to enter the ID on the product configuration file.

In this project you would create a pom.xml file which specifies the creation of a p2 update site for your product and the creation of a zip file.

For example the following shows such a pom.xml file.

<?xml version="1.0" encoding="UTF-8"?>
<project>
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <relativePath>../de.vogella.tycho.master/pom.xml</relativePath>
    <groupId>com.vogella</groupId>
    <artifactId>parent</artifactId>
    <version>1.0.0-SNAPSHOT</version>
  </parent>


  <artifactId>de.vogella.tycho.rcp.product</artifactId>
  <packaging>eclipse-repository</packaging>


  <name>de.vogella.tycho.rcp.product product build</name>
  <build>
    <plugins>
      <plugin>
        <groupId>org.eclipse.tycho</groupId>
        <artifactId>tycho-p2-repository-plugin</artifactId>
        <version>${tycho-version}</version>
        <configuration>
          <includeAllDependencies>true</includeAllDependencies>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.eclipse.tycho</groupId>
        <artifactId>tycho-p2-director-plugin</artifactId>
        <version>${tycho-version}</version>
        <executions>
          <execution>
            <id>materialize-products</id>
            <goals>
              <goal>materialize-products</goal>
            </goals>
          </execution>
          <execution>
            <id>archive-products</id>
            <goals>
              <goal>archive-products</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project> 

To build a product you need to build your own plug-ins and features. This process is the same as described earlier. Also the master configuration file is the same.

The following example shows a master pom.xml. In this example your Eclipse RCP application consists out of one plug-in and one feature.

<?xml version="1.0" encoding="UTF-8"?>
<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.vogella</groupId>
  <artifactId>parent</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <packaging>pom</packaging>
  <modules>
    <module>../de.vogella.tycho.rcp.application</module>
    <module>../de.vogella.tycho.rcp.feature</module>
    <module>../de.vogella.tycho.rcp.product</module>
  </modules>

  <properties>
    <tycho-version>0.16.0</tycho-version>
  </properties>

  <repositories>
    <repository>
      <id>juno</id>
      <layout>p2</layout>
      <url>http://download.eclipse.org/releases/juno</url>
    </repository>
  </repositories>

  <build>
    <plugins>
      <plugin>
        <groupId>org.eclipse.tycho</groupId>
        <artifactId>tycho-maven-plugin</artifactId>
        <version>${tycho-version}</version>
        <extensions>true</extensions>
      </plugin>

    </plugins>

  </build>

</project> 

To ensure that your product can be executed after the build, you have to set the start levels and the auto-start flag for the following plug-ins in your product configuration file on the Configuration tab,

org.eclipse.core.runtime Start-Level 2
org.eclipse.equinox.ds Start-Level  3
org.eclipse.equinox.event Start-Level 3 

8. Automatic deployment

You can use the Maven deployment artifact to deploy your artifacts, e.g. to an ftp server.

Add an entry for the user credentials to your local ~/m2/settings.xml file.

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <localRepository/>
  <interactiveMode/>
  <usePluginRegistry/>
  <offline/>
  <pluginGroups/>
  <servers>
    <server>
      <id>ftp-repository</id>
      <username>youruser</username>
      <password>yourpassword</password>
    </server>
  </servers>
  <mirrors/>
  <proxies/>
  <profiles/>
  <activeProfiles/>
</settings> 

You can then configure your pom.xml to use the deployment module of Maven.

<project>
  <distributionManagement>
    <repository>
      <id>ftp-repository</id>
      <url>ftp://repository.mycompany.com/repository</url>
    </repository>
  </distributionManagement>

  <build>
    <extensions>
      <!-- Enabling the use of FTP -->
      <extension>
        <groupId>org.apache.maven.wagon</groupId>
         <artifactId>wagon-ftp</artifactId>
         <version>1.0-beta-6</version>
      </extension>
    </extensions>
  </build>
</project> 

The following command will now deploy your artifacts to your ftp site.

mvn deploy 

If you only want to upload your p2 update site you can configure the org.apache.maven.wagon plug-in.

<?xml version="1.0" encoding="UTF-8"?>
<project>
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <relativePath>../de.vogella.tycho.master/pom.xml</relativePath>
    <groupId>com.vogella</groupId>
    <artifactId>parent</artifactId>
    <version>1.0.0-SNAPSHOT</version>
  </parent>

  <artifactId>de.vogella.tycho.p2updatesite</artifactId>
  <packaging>eclipse-repository</packaging>

  <name>Tycho Test Build</name>

 <build>
  <extensions>
   <!-- Enabling the use of FTP -->
   <extension>
    <groupId>org.apache.maven.wagon</groupId>
    <artifactId>wagon-ftp</artifactId>
    <version>1.0-beta-6</version>
   </extension>
  </extensions>
 </build>

 <profiles>
  <!-- This profile is used to upload the repo -->
  <profile>
   <id>uploadRepo</id>
   <properties>
    <!-- Properties relative to the 
    distant host where to upload the repo -->
    <ftp.url>ftp://your.server.com</ftp.url>
    <ftp.toDir>/yourpath</ftp.toDir>
    <!-- Relative path to the repo being uploaded -->
    <repo.path>${project.build.directory}/repository/</repo.path>
   </properties>

   <build>
    <plugins>
     <!-- Upload the repo to the server -->
     <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>wagon-maven-plugin</artifactId>
      <version>1.0-beta-4</version>
      <executions>
       <execution>
        <id>upload-repo</id>
        <phase>install</phase>
        <goals>
         <goal>upload</goal>
        </goals>
        <configuration>
         <fromDir>${repo.path}</fromDir>
         <includes>**</includes>
         <toDir>${ftp.toDir}</toDir>
         <url>${ftp.url}</url>
         <serverId>p2Repo</serverId>
         <!-- Points to your settings.xml 
         where the connection settings are 
          stored as shown below -->
         <!-- <server> -->
         <!-- <id>p2Repo</id> -->
         <!-- <username>username</username> -->
         <!-- <password>password</password> -->
         <!-- </server> -->
        </configuration>
       </execution>
      </executions>
     </plugin>
    </plugins>
   </build>
  </profile>
 </profiles>

</project> 

You can now upload your p2 update site with the following command.

mvn install -P uploadRepo 

9. Thank you

Please help me to support this article:

Flattr this

10. Questions and Discussion

Before posting questions, please see the vogella FAQ. If you have questions or find an error in this article please use the www.vogella.com Google Group. I have created a short list how to create good questions which might also help you.

11. Links and Literature

11.1. Source Code

Source Code of Examples

11.2. Maven Tycho Resources

Clone the Tycho Examples via clone git://git.eclipse.org/gitroot/tycho/org.eclipse.tycho-demo.git

Tycho Example project Tycho Book from the Tycho project

Tycho Example project Git repo "https://github.com/caniszczyk/minerva".

Tycho Reference Card

Tycho Target Platform

Maven deployment artifact