开发者

Maven / M2Eclipse excludes my resources all the time

开发者 https://www.devze.com 2023-04-12 23:13 出处:网络
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.

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, bu开发者_Go百科t 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


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.


T_T not a good solution. resources is not copied without maven-update


maven resources:resources phase marked ignored in Lifecycle Mappings will cause this problem.

As Miles pointed out above, eclipse don't copy the resource since it assumes maven will do it for you. Then if resources:resources phase which do the job in maven is not executed, you get a file not found exception at runtime.

to check this open

project->properties->maven->lifecycle mapping

and see whether resources:resources is marked ignored or not.

to solve it windows->preference->maven->lifecycle mapping-> open workspace lifecycle mappings metadata

then change

  <action>
    <ignore />
  </action>

to

  <action>
    <execute />
  </action>

for goal resources

reload metadata & update maven project

should solve the problem.


step 1. delete the project from eclipse step 2. import the project freshly step 3. Go to the folder required to be added as source folder.

Please refer below screen shot:

Maven / M2Eclipse excludes my resources all the time

0

精彩评论

暂无评论...
验证码 换一张
取 消