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>maven–antrun–plugin</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
Hi there,
Just found a trick to make Maven projects work without any additional tools as an OSGi bundle inside PDE:
http://blogs.nuxeo.com/dev/2010/11/working-with-osgi-and-maven-in-eclipse.html
Cheers
Sun.
Thanks! This also looks like an interesting approach.