Maven 2.x Eclipse Plugin

mvn eclipse:eclipse fails or doesn't generate proper .classpath when specifying the same resource directory with different filtering rules

Details

  • Number of attachments :
    1

Description

Let's say I have a resource directory (src/main/resources) that contains properties and XML and want to filter .properties only. My pom.xml is setup as follow:

<build>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
        <includes>
          <include>**/*.properties</include>
        </includes>
      </resource>
      <resource>
        <directory>src/main/resources</directory>
        <filtering>false</filtering>
        <excludes>
          <exclude>**/*.properties</exclude>
        </excludes>
      </resource>
    </resources>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-eclipse-plugin</artifactId>
        <version>2.7</version>
      </plugin>
    </plugins>
  </build>

This works fine when running maven on the command line. However, when I run mvn eclipse:eclipse with the eclipse plugin 2.7, the build just fails:

[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Request to merge when 'filtering' is not identical. Original=resource src/main/resources: output=target/classes, include=[**/*.properties], exclude=[**/*.java], test=false, filtering=true, merging with=resource src/main/resources: output=target/classes, include=[], exclude=[**/*.properties|**/*.java], test=false, filtering=false
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Wed Nov 25 18:47:32 CET 2009
[INFO] Final Memory: 8M/79M
[INFO] ------------------------------------------------------------------------

With the maven eclipse plugin version 2.6, the build passes but the .classpath doesn't contain the expected informations in the including attribute of the classpathentry src/main/resources, XML files are not included in the actual result:

code:xml
<classpath>
<classpathentry kind="src" path="src/test/java" output="target/test-classes" including="*/.java"/>
<classpathentry kind="src" path="src/main/java" including="*/.java"/>
<classpathentry kind="src" path="src/main/resources" including="*/.properties" excluding="*/.java"/>
<classpathentry kind="output" path="target/classes"/>
<classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar" sourcepath="M2_REPO/junit/junit/3.8.1/junit-3.8.1-sources.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
</classpath>
code

I'm not really sure what the expected result should be (should the union of */.properties and all other files that are not */.properties be */.*?) but the actual result is not correct.

Specifying sourceIncludes/sourcesExcludes (as documented here doesn't help (and it's not clear to me if it's the right things to do).

For now, I'm using the following setup (I've split filtered and non filtered resources into separate directories) as workaround:

code:xml
<resources>
<resource>
<directory>src/main/resources1</directory>
<filtering>true</filtering>
<includes>
<include>*/.properties</include>
</includes>
</resource>
<resource>
<directory>src/main/resources2</directory>
<filtering>false</filtering>
<includes>
<include>*/.xml</include>
</includes>
</resource>
</resources>
code

But still, there is clearly a regression between versions prior to 2.7 and 2.7. I'm attaching a project allowing to reproduce this.

Issue Links

Activity

Hide
Pascal Thivent added a comment -

Ooops, looks like I messed with the formatting... sorry for that.

Show
Pascal Thivent added a comment - Ooops, looks like I messed with the formatting... sorry for that.
Hide
Jason Thrasher added a comment -

There's a quickie workaround here that tells maven to use v2.6 of the plugin, regardless of the pom-specified version configuration:
http://mentalecho.com/blog/tag/Eclipse

However, I'd like my team to not have to make those kinds of changes, as lots of other issues are then introduced. For right now our workaround is to configure one filtered, and one non-filtered, directory as:
src/main/resources
src/main/resources-filtered

Show
Jason Thrasher added a comment - There's a quickie workaround here that tells maven to use v2.6 of the plugin, regardless of the pom-specified version configuration: http://mentalecho.com/blog/tag/Eclipse However, I'd like my team to not have to make those kinds of changes, as lots of other issues are then introduced. For right now our workaround is to configure one filtered, and one non-filtered, directory as: src/main/resources src/main/resources-filtered
Hide
Johan Walles added a comment -

Maybe fixing MECLIPSE-165 would be the best that can be done here? At least it would make the situation a little bit better.

Show
Johan Walles added a comment - Maybe fixing MECLIPSE-165 would be the best that can be done here? At least it would make the situation a little bit better.
Hide
fabrizio giustina added a comment -

Fixed for version 2.9, now the merging of resource dirs is always handled gracefully, without generating any error but at least just warning the user that the eclipse configuration may not exactly reflect the pom settings.
The result is now the same as the one from the eclipse plugins < 2.7. A few new test cases have been added.

Show
fabrizio giustina added a comment - Fixed for version 2.9, now the merging of resource dirs is always handled gracefully, without generating any error but at least just warning the user that the eclipse configuration may not exactly reflect the pom settings. The result is now the same as the one from the eclipse plugins < 2.7. A few new test cases have been added.

People

Vote (4)
Watch (5)

Dates

  • Created:
    Updated:
    Resolved: