Maven 2.x Eclipse Plugin

Ability to exclude filtered resources from eclipse's source directories

Details

  • Type: New Feature New Feature
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: 2.3
  • Fix Version/s: None
  • Component/s: PDE support
  • Labels:
    None
  • Testcase included:
    yes
  • Patch Submitted:
    Yes
  • Number of attachments :
    2

Description

Resources should be in the classpath from Eclipse's point of view because they end up being in the classpath from Maven 2's point of view, but whenever resources are marked as being filtered by M2, Eclipse puts them unfiltered in the classpath thus introducing an inconsistency between Maven 2 and Eclipse.

Whether or not to include filtered resource directories in eclipse's sources directories is therefore a real dilemna. While I'm sure a consistent solution to this dilemna will eventually be found, it would be great to let the user choose what to do in the meantime.

The attached patch adresses this issue by adding a parameter, 'excludeFilteredResourcesFromSourceDirs', which when set to true prevents filtered resource directories from being added to eclipse's source directories. The parameter defaults to false to avoid changing current projects' behavior.

Regards,

Cédric Vidal
http://www.B-Process.com

PS: This parameter could be overriden on a per resource directory basis as mentionned in MECLIPSE-162. This is not adressed by the attached patch though

  1. MECLIPSE-165.patch
    03/Oct/06 12:29 PM
    9 kB
    Cédric Vidal
  2. ResourceExcludes.patch
    27/Nov/09 8:46 AM
    2 kB
    Florian Kirchmeir

Issue Links

Activity

Hide
Cédric Vidal added a comment -

Here is the patch, it has been created with TortoiseSVN against the trunk relative to the root of maven-eclipse-plugin.

Regards,

Cédric Vidal
http://www.B-Process.com/

Show
Cédric Vidal added a comment - Here is the patch, it has been created with TortoiseSVN against the trunk relative to the root of maven-eclipse-plugin. Regards, Cédric Vidal http://www.B-Process.com/
Hide
Cédric Vidal added a comment -

Hi guys,

anyone interested in including this patch ?

Regards,

Cédric Vidal

Show
Cédric Vidal added a comment - Hi guys, anyone interested in including this patch ? Regards, Cédric Vidal
Hide
Richard van der Hoff added a comment -

I think this issue has been solved by MECLIPSE-48

Show
Richard van der Hoff added a comment - I think this issue has been solved by MECLIPSE-48
Hide
Geoffrey De Smet added a comment -

MECLIPSE-48 doesn't solve this: you don't want maven to exclude them, but you do want eclipse to exclude them.

Wouldn't it be a lot easier if by default the eclipse plugin just excludes all resources which are filtered by maven?
You never want eclipse to copy those for you... and most people create a separate "filtered-resources" directory anyway.

Show
Geoffrey De Smet added a comment - MECLIPSE-48 doesn't solve this: you don't want maven to exclude them, but you do want eclipse to exclude them. Wouldn't it be a lot easier if by default the eclipse plugin just excludes all resources which are filtered by maven? You never want eclipse to copy those for you... and most people create a separate "filtered-resources" directory anyway.
Hide
Cédric Vidal added a comment -

Excluding by default all resources which are filtered by maven might break existing installation, this is why the patch provides a parameter which defaults to false to avoid breaking existing installations while allowing people to change the behavior.

What's more, I'm curious how you people deal this that matter, I've had that problem since the begining of Maven 2 but it seems like you guys manage to deal with it, is there a known workaround ?

Regards,

Cédric

Show
Cédric Vidal added a comment - Excluding by default all resources which are filtered by maven might break existing installation, this is why the patch provides a parameter which defaults to false to avoid breaking existing installations while allowing people to change the behavior. What's more, I'm curious how you people deal this that matter, I've had that problem since the begining of Maven 2 but it seems like you guys manage to deal with it, is there a known workaround ? Regards, Cédric
Hide
Paul Spencer added a comment -

I have mentioned this issue in a post on Maven's users mailing list. The post is titled "I use resource filtering with the Eclipse plugin but, need filtered directories excluded." Basically I am asking for the ability to exclude filtered resources from the eclipse classpath.

Paul Spencer

Show
Paul Spencer added a comment - I have mentioned this issue in a post on Maven's users mailing list. The post is titled "I use resource filtering with the Eclipse plugin but, need filtered directories excluded." Basically I am asking for the ability to exclude filtered resources from the eclipse classpath. Paul Spencer
Hide
Cédric Vidal added a comment -

Hi Paul,

Glad to hear that you have the same need.

Regards,

Cédric

Show
Cédric Vidal added a comment - Hi Paul, Glad to hear that you have the same need. Regards, Cédric
Hide
Brian Fox added a comment -

Applied the patch and updated so it applied cleanly. The resulting classpath doesn't match the expected one. Although the resulting one actually has the excludes, the format seems curious to me. It's excluding */.java from the binary resources. The code is applied to a branch here: https://svn.apache.org/repos/asf/maven/plugins/branches/maven-eclipse-plugin-MECLIPSE-165

If you can look and provide a patch from this branch, then we can get it applied to trunk. Thanks.

Show
Brian Fox added a comment - Applied the patch and updated so it applied cleanly. The resulting classpath doesn't match the expected one. Although the resulting one actually has the excludes, the format seems curious to me. It's excluding */.java from the binary resources. The code is applied to a branch here: https://svn.apache.org/repos/asf/maven/plugins/branches/maven-eclipse-plugin-MECLIPSE-165 If you can look and provide a patch from this branch, then we can get it applied to trunk. Thanks.
Hide
Daniel Rijkhof added a comment -

I would really like this issue to be resolved.

-> a way to have resources in maven which do not end up in the classpath within eclipse

Show
Daniel Rijkhof added a comment - I would really like this issue to be resolved. -> a way to have resources in maven which do not end up in the classpath within eclipse
Hide
Kyle Lebel added a comment -

Any news on this? I'm currently using a work around, which processes the resources as an eclipse builder but it gets very clunky after every file save to have maven run it's builder.

Show
Kyle Lebel added a comment - Any news on this? I'm currently using a work around, which processes the resources as an eclipse builder but it gets very clunky after every file save to have maven run it's builder.
Hide
Jan Rudert added a comment -

Hello ? Any ETA for the release of the fix? I need it as well pretty urgently...

Show
Jan Rudert added a comment - Hello ? Any ETA for the release of the fix? I need it as well pretty urgently...
Hide
Brian Fox added a comment -

See my comment from July, the current patch is no longer valid and the tests fail.

Show
Brian Fox added a comment - See my comment from July, the current patch is no longer valid and the tests fail.
Hide
Sergio Aguado added a comment -

Any update of the fix? I need it in my current project. If there is any workaround please let me know

Show
Sergio Aguado added a comment - Any update of the fix? I need it in my current project. If there is any workaround please let me know
Hide
Connor Barry added a comment -

Any updates yet? This is really a crucial fix for anybody using filtered resources, which is a basic requirement of a lot of projects...

My workaround is to have a shell script that calls the maven goal, and additionally an ant script that modifies the resulting .classpath file to exclude ALL filtered resources, not only the */.java files. There's two regexes to account for the two possible attribute orders, which are seemingly random; just a hack, I'm sure there's a better way.

----------------------------- eclipse-config.bat:
@echo off
setlocal

set _REALPATH=%~dp0
cd %_REALPATH%

cls
call %M2_HOME%/bin/mvn eclipse:clean eclipse:eclipse
call %ANT_HOME%/bin/ant fix-classpath
pause

----------------------------- build.xml (add a bogus env target if necessary):

<?xml version="1.0"?>
<project name="xxx" default="env">
<target name="fix-classpath">
<echo message="Fixing the WTP settings..." />
<replaceregexp file=".classpath" byline="true">
<regexp pattern='(.)excluding="**/*\.java"(.)path="src/main/resources-filtered"(.*)' />
<substitution expression='\1excluding="*/"\2path="src/main/resources-filtered"\3' />
</replaceregexp>
<replaceregexp file=".classpath" byline="true">
<regexp pattern='(.)path="src/main/resources-filtered"(.)excluding="**/*\.java"(.*)' />
<substitution expression='\1excluding="*/"\2path="src/main/resources-filtered"\3' />
</replaceregexp>
</target>
</project>

Show
Connor Barry added a comment - Any updates yet? This is really a crucial fix for anybody using filtered resources, which is a basic requirement of a lot of projects... My workaround is to have a shell script that calls the maven goal, and additionally an ant script that modifies the resulting .classpath file to exclude ALL filtered resources, not only the */.java files. There's two regexes to account for the two possible attribute orders, which are seemingly random; just a hack, I'm sure there's a better way. ----------------------------- eclipse-config.bat: @echo off setlocal set _REALPATH=%~dp0 cd %_REALPATH% cls call %M2_HOME%/bin/mvn eclipse:clean eclipse:eclipse call %ANT_HOME%/bin/ant fix-classpath pause ----------------------------- build.xml (add a bogus env target if necessary): <?xml version="1.0"?> <project name="xxx" default="env"> <target name="fix-classpath"> <echo message="Fixing the WTP settings..." /> <replaceregexp file=".classpath" byline="true"> <regexp pattern='(.)excluding="**/*\.java"(.)path="src/main/resources-filtered"(.*)' /> <substitution expression='\1excluding="*/"\2path="src/main/resources-filtered"\3' /> </replaceregexp> <replaceregexp file=".classpath" byline="true"> <regexp pattern='(.)path="src/main/resources-filtered"(.)excluding="**/*\.java"(.*)' /> <substitution expression='\1excluding="*/"\2path="src/main/resources-filtered"\3' /> </replaceregexp> </target> </project>
Hide
Florian Kirchmeir added a comment -

I've implemented a "resourceExcludes" parameter, similar to the "sourceEcludes" added in version 2.7.
This way, you can at least manually configure stuff you want to have excluded.

Show
Florian Kirchmeir added a comment - I've implemented a "resourceExcludes" parameter, similar to the "sourceEcludes" added in version 2.7. This way, you can at least manually configure stuff you want to have excluded.

People

Vote (16)
Watch (18)

Dates

  • Created:
    Updated: