Maven Eclipse Plugin and Eclipse PDE: The Right Configuration

pom.xml

As noted on the Maven Eclipse plugin website, a two additional plugins need to be added to the project‘s pom. These copy the dependencies‘ jar files into the project folder and remove them on the eclipse:clean command. I found it helpful to add a further antrun plugin, which copies the MANIFEST.MF file generated by the maven bundle plugin. Therewith, the following additions can be made to the pom.xml

<!– MAVEN ECLIPSE PLUGIN –>
<!–

                                Dependency Plugin used to copy the dependency JARs into the root
                                project folder. There the Maven eclipse plugin will add them to the
                                classpath of PDE projects.
                        –>
                        <plugin>
                                <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>

                        <!–
                                Cleanup necessary because of PDE tweaks, clear the project directory
                        –>
                        <plugin>
                                <artifactId>maven-clean-plugin</artifactId>
                                <version>2.3</version>
                                <configuration>
                                        <filesets>
                                                <fileset>
                                                        <directory>${basedir}</directory>
                                                        <includes>
                                                                <include>*.jar</include>
                                                        </includes>
                                                        <followSymlinks>false</followSymlinks>
                                                </fileset>
                                        </filesets>
                                </configuration>
                        </plugin>

                        <!–
                                Keep the MANIFEST.MF used by eclipse in sync with the MANIFEST.MF
                                created by the maven bundle plugin
                        –>
                        <plugin>
                                <artifactId>mavenantrunplugin</artifactId>
                                <executions>
                                        <execution>
                                                <phase>package</phase>
                                                <goals>
                                                        <goal>run</goal>
                                                </goals>
                                                <configuration>
                                                        <tasks>
                                                                <delete file=“${basedir}/META-INF/MANIFEST.MF” />
                                                                <copy file=“target/classes/META-INF/MANIFEST.MF” tofile=“${basedir}/META-INF/MANIFEST.MF” />
                                                        </tasks>
                                                </configuration>
                                        </execution>
                                </executions>
                        </plugin>

Maven arguments

As mentioned before, Maven should be called with an additional argument to assure that the eclipse plugin does not attempt to define links between the eclipse plugins. One way of generating the eclipse meta-data is the following:

mvn eclipse:clean clean package eclipse:eclipse -Declipse.pde -Declipse.useProjectReferences=false install

4 thoughts on “Maven Eclipse Plugin and Eclipse PDE: The Right Configuration

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