You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Benjamin Bentmann (JIRA)" <ji...@codehaus.org> on 2007/11/01 19:28:10 UTC

[jira] Updated: (MECLIPSE-335) Nested compile source roots in effective POM cause bad Eclipse build path

     [ http://jira.codehaus.org/browse/MECLIPSE-335?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Benjamin Bentmann updated MECLIPSE-335:
---------------------------------------

    Attachment: nested-source-roots.patch

After a look at the source code of MavenProject, I discovered that it actually contains some logic to avoid multiple additions of the same source root. This encouraged me to extend its logic to ignore nested source roots as well, see the attached patch.

Assume a POM with a single compile source root of "src/main/java". The patch intents to realize the following behavior, each time considering the original POM named before:
- adding "src/main/java" should be ignored (like is now)
- adding "src/main/java/org/apache/maven" should be ignored
- adding "src/main" should discard "src/main/java" as a source root but use "src/main" instead

I could not think of a practical use-case that would trigger the third case but I wanted to guarantee the invariant that no nested source roots exists, regardless of their order of addition.

The unit test MavenProjectTest is also extended to capture the new behavior.

> Nested compile source roots in effective POM cause bad Eclipse build path
> -------------------------------------------------------------------------
>
>                 Key: MECLIPSE-335
>                 URL: http://jira.codehaus.org/browse/MECLIPSE-335
>             Project: Maven 2.x Eclipse Plugin
>          Issue Type: Bug
>    Affects Versions: 2.4
>         Environment: Maven 2.0.7, JDK 1.5.0_12, WinXP
>            Reporter: Benjamin Bentmann
>         Attachments: nested-source-roots.patch, nested-sources.zip
>
>
> Source generating plugins like for JavaCC or JFlex usually add their output folder to the POM as a compile source root. If these source directories happen to be nested, i.e. "src/main/java" and additional something like "src/main/java/org/apache", mvn eclipse:eclipse produces the following bad .classpath contents with overlapping build paths:{code:xml}
> <classpath>
>   <classpathentry kind="src" path="src/main/java"/>
>   <classpathentry kind="src" path="src/main/java/org/apache"/>
>   ...
> </classpath>
> {code}
> While this issues relates to MECLIPSE-114, I really think my problem is caused by Maven.
> Though the maven-eclipse-plugin causes the problem to manifest itself, it might not be the proper place to solve it as it appears to be a more general issue (i.e. the Maven Eclipse Integration might also be affected, though I did not test this). Surely, each and every plugin developer could be told to check for source directory nesting but I consider this an error-prone approach. I would rather appreciate either that MavenProject.addCompileSourceRoot() automatically ignores nested source directories (if such a general change is acceptable) or that new methods in MavenProject are introduced that allow for conditional addition of source roots only if they do not nest with existing roots such that plugin developers can easily fix the problem.

-- 
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