Eclipse Plugin Development Environment support

The Eclipse plugin supports creating configurations for Eclipse PDE (Plugin Development Environment).

These configurations can be used to create Eclipse plugins, features, or Eclipse RCP products.

Note that the scope of the maven-eclipse-plugin is to synchronise the Eclipse .project and .classpath files with the configuration found in the pom file. Once you have finished configuring the Eclipse plugin as below, and once you have run the eclipse:eclipse goal, you will be in a position to build your plugin code with the Eclipse IDE, or the Eclipse headless PDE build. The Eclipse headless PDE build can be triggered from within Maven using the pde-maven-plugin.

Enabling PDE support

Enabling support for PDE is achieved by setting the pde flag to true within the configuration.

      <plugin>
        <artifactId>maven-eclipse-plugin</artifactId>
        <configuration>
          <pde>true</pde>
        </configuration>
      </plugin>

Eclipse PDE configuration

When PDE support is enabled in the maven-eclipse-plugin, the Eclipse project files are configured differently to the default. These differences are explained below.

  • Plugin Nature

    The org.eclipse.pde.PluginNature is added to the list of eclipse project natures, indicating to Eclipse that this project is a PDE project.

  • Plugin Dependencies

    The Plugin Dependencies library is added to the Eclipse classpath. This Eclipse library resolves Eclipse/OSGI dependencies, and removes the need for maven to depend explicitly on eclipse jars.

  • Linked Resources

    In order for the Eclipse PDE system to build or deploy an Eclipse PDE project, it requires that dependent jars exist somewhere within the project itself.

    By default, the eclipse:eclipse goal sets up the Eclipse classpath such that the project depends on jars in the external local maven repository. When PDE mode is enabled, dependencies are configured as Eclipse linked resources instead.

    Eclipse linked resources work like symbolic links within the Eclipse IDE. These linked resources appear in the root directory of your PDE project, and link the jars within your repository into the root of your project as required by Eclipse.

    Note: Linked resources are correctly referenced from the Eclipse IDE, however due to a limitation of the Eclipse headless PDE build, linked resources are not correctly referenced from the Eclipse headless PDE build. As a result, attempts to use the Eclipse export wizard to export your plugin, feature or product, and attempts to use the pde-maven-plugin to do so will fail, despite the same build working in the IDE.

    The workaround is to use the maven-dependency-plugin to copy your dependent jars into the root of your project before running Eclipse. The maven-clean-plugin is configured to remove these jar files on mvn clean. Don't forget to configure your source control server to ignore *.jar files in the root directory of your project.

          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
              <execution>
                <id>copy-dependencies</id>
                <phase>process-sources</phase>
                <goals>
                  <goal>copy-dependencies</goal>
                </goals>
                <configuration>
                  <outputDirectory>${basedir}</outputDirectory>
                  <overWriteReleases>false</overWriteReleases>
                  <overWriteSnapshots>false</overWriteSnapshots>
                  <overWriteIfNewer>true</overWriteIfNewer>
                </configuration>
              </execution>
            </executions>
          </plugin>
     
          <plugin>
            <artifactId>maven-clean-plugin</artifactId>
            <configuration>
              <filesets>
                <fileset>
                  <directory>${basedir}</directory>
                  <includes>
                    <include>*.jar</include>
                  </includes>
                  <followSymlinks>false</followSymlinks>
                 </fileset>
               </filesets>
             </configuration>
           </plugin>

Building PDE Code

Having configured Eclipse correctly using maven-eclipse-plugin, the task of building your PDE project is a job for one or more of: