Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
623 views
in Technique[技术] by (71.8m points)

eclipse - Maven / M2Eclipse excludes my resources all the time

I have two very annoying issues with Maven-Eclipse integration, from time to time it excludes all my resources in src/main/resources and src/test/resources from the build path.

If I inspect "Properties >> Java Build Path >> Source" I can see that these two folders have "Excluded: **".

The problem can be easily solved by clicking on "Remove" on the exclusions, but it is really-really frustrating.

The project setup is very simple, it has some modules and sub-modules, but nothing fancy. I don't have any configuration options in my pom.xmls regarding resources, eclipse or whatever (maybe I should?).

The other problem is that Eclipse keeps reporting warnings in the "target" directories (in the "Problems" view), where it shouldn't give a damn in the first place.

Ps: Springsource Tool Suite 2.7.0.RELEASE, Maven Integration for Eclipse 0.12.1.20110112, Maven 2.2.1

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This is correct behavior. Current version of M2E provide their own contributor to the automatic build process inside the Eclipse IDE. This build process takes into account the maven lifecycle for generate-resources and process-resources etc... i.e. some project have plugins that generate resources from configuration and put in the compiled output folder.

The mechanism you are looking at in the Build Path only relates to the Eclipse IDEs built in mechanism to compile/assembly a set of input source folders into the output folders. If both Maven and Eclipse did this there would be conflicts/problems.

There is a link in the M2E FAQ about this exact point https://www.eclipse.org/m2e/documentation/m2e-faq.html#how-to-configure-proxy-and-location-of-maven-local-repository

If you are genuinely having problems with resources not being copied maybe we can work through why that is (since that is another matter), but your main question is about a common M2E FAQ point.

Maybe you want to upgrade to org.eclipse.m2e and Indigo as a lot of Maven complex maven issues/usage I have are mostly resolved or have an explained solution.

.

I would recommend you perform a "Run As -> Maven -> clean" and then a "Project -> Clean" then enable automatic bulding (this is to allow Eclipse based automatic build to take place, do not use Run As -> Maven to build to test this point). Now open a file manager outside eclipse and manually inspect the output folders for the resources that you did not think are being copied. You should find they are there just the same.

.

I agreed with the (probably Validation) warning about items in the target/** directory and whilst Eclipse has a way to manually exclude the target/** directory from validation this option does not stick beyond a project clean (when the target directory is deleted).

So it is somewhat annoying to be always waiting for validation of items in a large project.

Maybe I attempt to see if a Maven Eclipse connector plugin can be created provided to do this i.e. tie into the build lifecycle and automatically apply the Exclude Validation on the target folder.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...