On Wed, October 31, 2007 11:43 am, Michal Paluchowski wrote:
> Took a day or two to actually find out how to put the scraps of
> information there together and install the custom MOJOs. Once I did
> that, Eclipse project files were perfectly generated by 'mvn
> eclipse:eclipse', all projects built in Eclipse but... not in Maven.
> Even though Maven knew that the project depends on the org.eclipse.ui
> package in the MANIFEST file (and complained if that package was not
> in the repository), it still reported missing dependencies once the
> packages were available to it in its repo.
I am having a sense of deja vu :)
By way of background, things will make a lot more sense when you know
exactly what the eclipse plugin does, and the pde plugin does, and the gap
in between the two that complicates everything.
First, the maven-eclipse-plugin:
The purpose of this plugin is to take information from maven-land, such as
your dependences and other config, and synchronise your eclipse
configuration with this information. Or in short, maven-eclipse-plugin
causes config data to flow from maven to eclipse, nothing more. The PDE
flag in the eclipse plugin causes more of the eclipse config to be
synchronised, particularly the META-INF/MANIFEST.MF data, but the
principle is the same.
Second, the pde-maven-plugin:
The purpose of this plugin is invoke the PDE build feature of Eclipse,
nothing more, and its PDE where the fun starts.
Eclipse has two different mechanisms for compiling code. The first is the
built in build process in the Eclipse frontend itself. The second is an
ant based system called PDE (plugin development environment) that is able
to build Eclipse projects from the command line.
Unfortunately it is not difficult to create a configuration in Eclipse
which will build successfully inside the Eclipse frontend, but not build
in the PDE environment, particularly when your eclipse plugin has
plain-old-jar-dependencies as dependencies.
The reason for this is that the Eclipse frontend supports the idea of
"linked resources", which work like symbolic links. When the
maven-eclipse-plugin creates the .project and .classpath files, it creates
these "linked resources" for you, pointing at the jars in the local maven
repository.
The problem is that this "linked resources" feature in the Eclipse
frontend isn't supported in the Eclipse PDE ant build. The PDE build takes
the "linked resources" literally, interpreting them as jars existing in
the root of your plugin project, and because they don't exist in the root
of your project, the PDE build fails.
Because the PDE build fails, the pde-maven-plugin fails, and in turn, your
maven build fails.
The workaround is to fool the Eclipse PDE build into working by physically
copying the dependencies you need into the root of your plugin project.
Obviously you don't want to do this manually, so you configure the
maven-dependency-plugin to do the copying for you in the "process-sources"
phase at the start of the maven build, and configure the
maven-clean-plugin to delete all of these copied jars when you run "mvn
clean".
The relevant bits of our pom look like this:
<!-- tell the eclipse plugin this is a PDE project.
This plugin is bound to the validate phase to
ensure the Eclipse dependencies are always up to date.
we inherit the version from the version specified in
the root pom.
-->
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
<executions>
<execution>
<id>synchronise-eclipse</id>
<phase>validate</phase>
<goals>
<goal>eclipse</goal>
</goals>
</execution>
</executions>
<configuration>
<pde>true</pde>
</configuration>
</plugin>
<!-- copy dependencies into the local build tree, as
required by PDE.
This step is a workaround for the fact that Eclipse PDE build
script does not properly support the Eclipse linked resources
feature.
-->
<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>
<excludeScope>provided</excludeScope>
<outputDirectory>${basedir}</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
<!-- clean plugin to delete jar files copied above -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<configuration>
<filesets>
<fileset>
<directory>${basedir}</directory>
<includes>
<include>*.jar</include>
</includes>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
</configuration>
</plugin>
<!-- plugin to build this as an eclipse rcp package -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>pde-maven-plugin</artifactId>
<!--
Note: We use our own private copy of pde-maven-plugin until bug
http://jira.codehaus.org/browse/MOJO-862 has been fixed.
-->
<version>1.0-alpha-2-private</version>
<extensions>true</extensions>
<configuration>
<eclipseInstall>${env.ECLIPSE_HOME}</eclipseInstall>
<pdeProductFilename>alchemy-eclipse.product</pdeProductFilename>
<pdeBuildVersion>3.2.1.r321_v20060823</pdeBuildVersion>
<pdeBuildConfigDirectory>/</pdeBuildConfigDirectory>
<antVerbose>false</antVerbose>
<antDebug>false</antDebug>
<!-- javacFailOnError>true</javacFailOnError-->
</configuration>
<executions>
<!-- Also bind to mvn clean -->
<execution>
<id>clean-pde</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
There are also issues with directory structure, but I'll cover these in a
separate mail.
Regards,
Graham
--
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]