WTP component file is sometimes missing libraries if the POM lists multiple
artifact types with the same artifact ID
--------------------------------------------------------------------------------------------------------------------
Key: MECLIPSE-217
URL: http://jira.codehaus.org/browse/MECLIPSE-217
Project: Maven 2.x Eclipse Plugin
Issue Type: Bug
Components: WTP support
Affects Versions: 2.3
Reporter: DJ Gregor
Attachments: diffs
A number of the projects in our application require not only the binary JAR
from another project, but also the test JAR. When generating the Eclipse WTP
configuration files with the plugin, some of these libraries needed at runtime
are not put in the component file, and cause the webapp to not be functional.
The behavior is not always consistent--sometimes all libraries will be there,
or one or more will be missing.
Here's an example of from our POM (which can be seen in whole here:
<http://opennms.svn.sourceforge.net/viewvc/opennms/opennms/trunk/opennms-webapp/pom.xml?view=markup>):
<dependency>
<groupId>org.opennms</groupId>
<artifactId>opennms-dao</artifactId>
</dependency>
<!-- XXX the required test JARs should be moved into a separate project -->
<dependency>
<groupId>org.opennms</groupId>
<artifactId>opennms-dao</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
Notice that we have opennms-dao listed twice, once to get the binary JAR, and
once for the test JAR. This works fine with Maven from the command line and
works fine within Eclipse until we go to deploy a webapp with WTP.
AbstractIdeSupportMojo.doDependencyResolution() keeps a HashSet of projects
that have already been added to the dependency list in emittedReactorProjectId,
keyed on the group ID and artifact ID of the project. Since our project
requires multiple artifacts of different types from the same project, only one
dependency makes it into the list that
AbstractIdeSupportMojo.doDependencyResolution() returns. This wouldn't be a
problem, except sometimes instead of our runtime dependency making it in first,
the dependency that makes it in is the test dependency which later gets thrown
out by AbstractWtpResourceWriter.writeWarOrEarResources.
The attached patch changes the key used for inserting values into the
emittedReactorProjectId HashSet to include the artifact type. The
EclipseProjectWriter and EclipseClasspathWriter need to only print out unique
artifact IDs (which are Eclipse projects), so they each keep their own HashSet
keyed on artifact ID to ensure that an artifact ID is only emitted once.
This patch solves this problem that I've been having on OpenNMS. I will work
on unit tests for these changes as I have time.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira