Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 351092 - Don't force Java Build Path Excluded: ** if a custom Lifecyle Mapping is used
Summary: Don't force Java Build Path Excluded: ** if a custom Lifecyle Mapping is used
Status: CLOSED WORKSFORME
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: m2e (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-04 09:40 EDT by Michael Vorburger CLA
Modified: 2021-04-19 13:24 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Vorburger CLA 2011-07-04 09:40:55 EDT
This issue suggests that at least when a Custom Lifecycle Mapping is defined, so when Project > Properties > Maven > Lifecycle Mapping shows e.g. org.maven.ide.eclipse.jdt.javaConfigurator instead of the default Generic Lifecycle mapping, then the Project Configuration shall not not put the Java Build Path Excluded: ** on resource folders.


This is yet another rant ;) about the well-known Java Build Path Excluded: ** story in M2E (see e.g. http://jira.codehaus.org/browse/MNGECLIPSE-784, http://jira.codehaus.org/browse/MNGECLIPSE-997, http://jira.codehaus.org/browse/MNGECLIPSE-864, http://jira.codehaus.org/browse/MNGECLIPSE-823, http://jira.codehaus.org/browse/MNGECLIPSE-696, http://jira.codehaus.org/browse/MNGECLIPSE-457).  Also http://stackoverflow.com/questions/5137584/maven-eclipse-the-default-build-path-for-resources-excluded-everything and other similar ones found when searching.

I *DO* understand then original intention (that M2E would let the Maven Builder delegate the 'appropriate' resource copying, with filtering, to Maven; and that this forced default configuration is intended to prevent Eclipse JDT Builder from copying resources).  But please accept that, as is evident from the many many bug reports, that this functionality just doesn't work reliably enough for end-users.

We have learnt that via a "Custom Lifecyle Mapping" (e.g. https://docs.sonatype.org/display/M2ECLIPSE/Customizable+build+lifecycle+mapping+for+m2e+extensions+developers) it is possible to stop M2E from trying to delegate resource copying to Maven, and use the normal Eclipse processing (which works well for us, we don't have any need to filters resources).

This set-up is used in both a proprietary in-house codebase as well as in the Mifos OSS project (see http://mifosforge.jira.com/wiki/display/MIFOS/Workspace+2.0+Eclipse+Maven+Settings#Workspace2.0EclipseMavenSettings-EclipseSettingsforMavenoptimization).

What remains annoying is that menu Maven > Update Project Configuration will STILL put the Java Build Path Excluded: ** on resource source folders!  This proposal would address that (if one configures a custom Lifecyle Mapping).

With version 0.12.1 at least it does not currently behave like this.
Comment 1 Igor Fedorenko CLA 2011-07-04 10:15:28 EDT
You should be able to do this in m2e 1.0 already. Very rough implementation idea. 

1. Implement custom project configurator that extends org.eclipse.m2e.jdt.internal.AbstractJavaProjectConfigurator and configures project source folders as necessary.
2. In pom.xml file of your project (or parent pom), map maven-compiler-plugin with compilerId=javac to the custom project configurator from start 1 above. See [1] for the standard mapping
3. In pom.xml file of your project (or parent pom), map maven-resources-plugin resources and testResources goals to <ignore/> action.

You can read more about m2e build lifecycle mapping and extensions development in [2] and [3]. Please ask any further questions on m2e-dev@eclipse.org mailing list

[1] http://git.eclipse.org/c/m2e/m2e-core.git/tree/org.eclipse.m2e.jdt/lifecycle-mapping-metadata.xml?id=releases/1.0/1.0.0.20110607-2117
[2] http://wiki.eclipse.org/M2E_plugin_execution_not_covered
[3] http://wiki.eclipse.org/M2E_Extension_Development
Comment 2 Denis Roy CLA 2021-04-19 13:24:19 EDT
Moved to https://github.com/eclipse-m2e/m2e-core/issues/