Maven 2.x Eclipse Plugin

[regression] Resources are excluded if resource dir equals source dir

Details

  • Number of attachments :
    0

Description

<build>
  <resources>
    <resource>
      <directory>src/main/java</directory>
      <includes>
        <include>**/*.properties</include>
      </includes>
    </resource>
  </resources>
</build>

For a non-standard project layout like sketched above where some resource files reside next to the source files (e.g. Messages.properties in Mercury), the change for MECLIPSE-443 causes these resources files to be excluded from the build path since they don't match the filter "*/.java". This can for instance cause test failures in Eclipse due to resources missing on the class path.

When source and resource directories equal, the includes/excludes need to be merged.

Issue Links

Activity

Hide
Ralf Ebert added a comment -

As "workaround" for this issue one can downgrade the maven-eclipse-plugin:

<!--
	downgraded to 2.5.1 because of
	http://jira.codehaus.org/browse/MECLIPSE-443
	http://jira.codehaus.org/browse/MECLIPSE-551
	(resource settings for src/main/java are ignored in general)
-->
<plugin>
	<artifactId>maven-eclipse-plugin</artifactId>
	<version>2.5.1</version>
</plugin>

Mainly for historical reasons I have resource files in src/main/java and include them in the maven build like this:

<resources>
	<resource>
		<directory>src/main/java</directory>
		<includes>
			<include>**/*</include>
		</includes>
		<excludes>
			<exclude>**/*.java</exclude>
			<exclude>**/*.sample</exclude>
		</excludes>
	</resource>
</resources>

This works perfectly for the mvn build and maven-eclipse-plugin 2.5.1. Since maven-eclipse-plugin 2.6 this is not reflected by the generated eclipse project configuration any more.

Ralf Ebert
http://www.ralfebert.de/

Show
Ralf Ebert added a comment - As "workaround" for this issue one can downgrade the maven-eclipse-plugin:
<!--
	downgraded to 2.5.1 because of
	http://jira.codehaus.org/browse/MECLIPSE-443
	http://jira.codehaus.org/browse/MECLIPSE-551
	(resource settings for src/main/java are ignored in general)
-->
<plugin>
	<artifactId>maven-eclipse-plugin</artifactId>
	<version>2.5.1</version>
</plugin>
Mainly for historical reasons I have resource files in src/main/java and include them in the maven build like this:
<resources>
	<resource>
		<directory>src/main/java</directory>
		<includes>
			<include>**/*</include>
		</includes>
		<excludes>
			<exclude>**/*.java</exclude>
			<exclude>**/*.sample</exclude>
		</excludes>
	</resource>
</resources>
This works perfectly for the mvn build and maven-eclipse-plugin 2.5.1. Since maven-eclipse-plugin 2.6 this is not reflected by the generated eclipse project configuration any more. Ralf Ebert http://www.ralfebert.de/
Hide
Ari Meyer added a comment -

Similarly, this kills Wicket users who follow the standard practice of having the corresponding HTML template file in the same dir as the Java source file. (Yes, one could put HTML files in another directory structure, but that's not the typical practice.) I've reverted to 2.5.1, which works fine, but please release a fix soon!

Thanks,
Ari

Show
Ari Meyer added a comment - Similarly, this kills Wicket users who follow the standard practice of having the corresponding HTML template file in the same dir as the Java source file. (Yes, one could put HTML files in another directory structure, but that's not the typical practice.) I've reverted to 2.5.1, which works fine, but please release a fix soon! Thanks, Ari
Hide
Arnaud Heritier added a comment -

We understand and we are sorry. We didn't think about this case. There are so many usages to handle in the plugin
We sent an email on the users list to help us to test the 2.7-SNAPSHOT but we received few feedback.
http://n2.nabble.com/-maven-eclipse-plugin--We-need-your-help-to-test-the-future-2.7-td2646905.html#a2646905
Let us know if solves the issue. We'll release it quickly if it is good.

Show
Arnaud Heritier added a comment - We understand and we are sorry. We didn't think about this case. There are so many usages to handle in the plugin We sent an email on the users list to help us to test the 2.7-SNAPSHOT but we received few feedback. http://n2.nabble.com/-maven-eclipse-plugin--We-need-your-help-to-test-the-future-2.7-td2646905.html#a2646905 Let us know if solves the issue. We'll release it quickly if it is good.
Hide
Ari Meyer added a comment -

Hi, Arnaud. I will try and test it – sorry, I wasn't on the mail list.

Merci!
Ari

Show
Ari Meyer added a comment - Hi, Arnaud. I will try and test it – sorry, I wasn't on the mail list. Merci! Ari
Hide
Ari Meyer added a comment -

Also, since this breaks builds/deployments for so many users, it might be worthwhile to put up a warning on the main page: http://maven.apache.org/plugins/maven-eclipse-plugin/index.html. I spent a lot of time debugging what appeared to be bizarre errors from my code (should have made this one change separately from my other changes, but...). Had I known about this issue, I wouldn't have upgraded to 2.6.

Thanks again,
Ari

Show
Ari Meyer added a comment - Also, since this breaks builds/deployments for so many users, it might be worthwhile to put up a warning on the main page: http://maven.apache.org/plugins/maven-eclipse-plugin/index.html. I spent a lot of time debugging what appeared to be bizarre errors from my code (should have made this one change separately from my other changes, but...). Had I known about this issue, I wouldn't have upgraded to 2.6. Thanks again, Ari
Hide
Barrie Treloar added a comment -

The problem is two fold.

One, for paths that are identical the code silently ignored them because internally they are represented as a Set and the usage of the add() method did not check the return value for success.

The second problem is that handling paths that overlap isn't as trivial as you would like.

The following describes how it is handled.

Adding a resource that maps to an existing directory will attempt to merge the new resources into the already added directory.

If one directory is a source and the other is a resource directory then the result will be a source directory and
any includes or excludes will be removed since Eclipse has no "main", "test" or "resource" concepts. The output directory will be the source directories value.

If the two directories are the same resources type (i.e isResource is equal) then the result will be the same resource type with the includes from each merged together (duplicates will be removed), similarly for the
excludes. No effort is made to ensure that the includes and excludes are disjointed sets. Please fix your pom instead. The output directories must match.

There is no support for cases where the test, or filtering values are not identical.

The IT test "project-53-MECLIPSE-551" was created using the wicket quickstart http://wicket.apache.org/quickstart.html and returns a .classpath with no include/exclude for overlapping source directories.
And so should behave like version 2.5.1.

Show
Barrie Treloar added a comment - The problem is two fold. One, for paths that are identical the code silently ignored them because internally they are represented as a Set and the usage of the add() method did not check the return value for success. The second problem is that handling paths that overlap isn't as trivial as you would like. The following describes how it is handled. Adding a resource that maps to an existing directory will attempt to merge the new resources into the already added directory. If one directory is a source and the other is a resource directory then the result will be a source directory and any includes or excludes will be removed since Eclipse has no "main", "test" or "resource" concepts. The output directory will be the source directories value. If the two directories are the same resources type (i.e isResource is equal) then the result will be the same resource type with the includes from each merged together (duplicates will be removed), similarly for the excludes. No effort is made to ensure that the includes and excludes are disjointed sets. Please fix your pom instead. The output directories must match. There is no support for cases where the test, or filtering values are not identical. The IT test "project-53-MECLIPSE-551" was created using the wicket quickstart http://wicket.apache.org/quickstart.html and returns a .classpath with no include/exclude for overlapping source directories. And so should behave like version 2.5.1.

People

Vote (3)
Watch (4)

Dates

  • Created:
    Updated:
    Resolved: