views:

843

answers:

2

I am trying out m2eclipse, the Eclipse plugin for Maven, and have noticed that the resources are now excluded from the build path of all my projects.

I have seen a question on the M2Eclipse FAQ page which seems to deal with this exact question, but the answer (paraphrased) seems to say that this is intentional to allow resource filtering, and everything Should Just Work.

However, when I run my application from within Eclipse, lots of my resources in dependent projects are failing to get found by my application.

I have tried my usual Eclipse waving-a-rubber-chicken actions (cleaning all projects, starting with -clean) to no avail. I'm sure I'm missing something fairly simple. Does anyone have any suggestions?

EDIT: Some digging in the m2 console has revealed that one of the projects is not building correctly. I get a ClassNotFoundException when it tries to find org.apache.maven.plugin.MojoFailureException in a custom plugin used to build one of the projects.

org.apache.maven.lifecycle.LifecycleExecutionException: Internal error in the plugin manager executing goal 'ourdemain:ourcustomplugin:2.0:process': Mojo execution failed.
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:505)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegmentForProject(DefaultLifecycleExecutor.java:265)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:191)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:149)
    at org.apache.maven.DefaultMaven.execute_aroundBody0(DefaultMaven.java:223)
    at org.apache.maven.DefaultMaven.execute_aroundBody1$advice(DefaultMaven.java:304)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:1)
    at org.apache.maven.embedder.MavenEmbedder.execute_aroundBody2(MavenEmbedder.java:904)
    at org.apache.maven.embedder.MavenEmbedder.execute_aroundBody3$advice(MavenEmbedder.java:304)
    at org.apache.maven.embedder.MavenEmbedder.execute(MavenEmbedder.java:1)
    at org.maven.ide.eclipse.internal.project.DefaultBuildParticipant$1.execute(DefaultBuildParticipant.java:130)
    at org.maven.ide.eclipse.internal.project.MavenProjectManagerImpl.execute(MavenProjectManagerImpl.java:986)
    at org.maven.ide.eclipse.internal.project.MavenProjectFacade.execute(MavenProjectFacade.java:320)
    at org.maven.ide.eclipse.internal.project.DefaultBuildParticipant.executePostBuild(DefaultBuildParticipant.java:116)
    at org.maven.ide.eclipse.internal.project.DefaultBuildParticipant.build(DefaultBuildParticipant.java:80)
    at org.maven.ide.eclipse.internal.builder.MavenBuilder.build(MavenBuilder.java:84)
    at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:633)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:170)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:201)
    at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:253)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:256)
    at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:309)
    at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:341)
    at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:140)
    at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:238)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: org.apache.maven.plugin.PluginExecutionException: Mojo execution failed.
    at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:601)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:498)
    ... 27 more
Caused by: org.apache.maven.plugin.MojoExecutionException: org/apache/maven/plugin/MojoFailureException
    at org.codehaus.mojo.ruby.DefaultRubyMojo.execute(DefaultRubyMojo.java:98)
    at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:579)
    ... 28 more
Caused by: java.lang.NoClassDefFoundError: org/apache/maven/plugin/MojoFailureException
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
    at java.lang.Class.getConstructor0(Class.java:2699)
    at java.lang.Class.getConstructor(Class.java:1657)
    at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:587)
    at org.jruby.javasupport.Java.new_proxy_instance(Java.java:570)
    at org.jruby.javasupport.JavaInvokerSnew_proxy_instancexx1.call(Unknown Source)
    at org.jruby.runtime.callback.InvocationCallback.execute(InvocationCallback.java:49)
    at org.jruby.internal.runtime.methods.FullFunctionCallbackMethod.internalCall(FullFunctionCallbackMethod.java:79)
    at org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:79)
    at org.jruby.evaluator.EvaluationState.callNode(EvaluationState.java:577)
    at org.jruby.evaluator.EvaluationState.evalInternal(EvaluationState.java:206)
    at org.jruby.evaluator.EvaluationState.setupArgs(EvaluationState.java:2182)
    at org.jruby.evaluator.EvaluationState.attrAssignNode(EvaluationState.java:481)
    at org.jruby.evaluator.EvaluationState.evalInternal(EvaluationState.java:191)
    at org.jruby.evaluator.EvaluationState.blockNode(EvaluationState.java:522)
    at org.jruby.evaluator.EvaluationState.evalInternal(EvaluationState.java:200)
    at org.jruby.evaluator.EvaluationState.eval(EvaluationState.java:163)
    at org.jruby.internal.runtime.methods.DefaultMethod.internalCall(DefaultMethod.java:167)
    at org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:79)
    at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:125)
    at org.jruby.evaluator.EvaluationState.callNode(EvaluationState.java:564)
    at org.jruby.evaluator.EvaluationState.evalInternal(EvaluationState.java:206)
    at org.jruby.evaluator.EvaluationState.callNode(EvaluationState.java:544)
    at org.jruby.evaluator.EvaluationState.evalInternal(EvaluationState.java:206)
    at org.jruby.evaluator.EvaluationState.localAsgnNode(EvaluationState.java:1230)
    at org.jruby.evaluator.EvaluationState.evalInternal(EvaluationState.java:285)
    at org.jruby.evaluator.EvaluationState.rescueNode(EvaluationState.java:1522)
    at org.jruby.evaluator.EvaluationState.evalInternal(EvaluationState.java:349)
    at org.jruby.evaluator.EvaluationState.ensureNode(EvaluationState.java:980)
    at org.jruby.evaluator.EvaluationState.evalInternal(EvaluationState.java:246)
    at org.jruby.evaluator.EvaluationState.eval(EvaluationState.java:163)
    at org.jruby.internal.runtime.methods.DefaultMethod.internalCall(DefaultMethod.java:167)
    at org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:79)
    at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:125)
    at org.jruby.evaluator.EvaluationState.fCallNode(EvaluationState.java:1019)
    at org.jruby.evaluator.EvaluationState.evalInternal(EvaluationState.java:252)
    at org.jruby.evaluator.EvaluationState.blockNode(EvaluationState.java:522)
    at org.jruby.evaluator.EvaluationState.evalInternal(EvaluationState.java:200)
    at org.jruby.evaluator.EvaluationState.rootNode(EvaluationState.java:1622)
    at org.jruby.evaluator.EvaluationState.evalInternal(EvaluationState.java:355)
    at org.jruby.evaluator.EvaluationState.eval(EvaluationState.java:163)
    at org.jruby.Ruby.eval(Ruby.java:274)
    at org.codehaus.plexus.component.jruby.JRubyRuntimeInvoker.runInterpreter(JRubyRuntimeInvoker.java:392)
    at org.codehaus.plexus.component.jruby.JRubyRuntimeInvoker.invoke(JRubyRuntimeInvoker.java:313)
    at org.codehaus.mojo.ruby.DefaultRubyMojo.execute(DefaultRubyMojo.java:81)
    ... 29 more
Caused by: java.lang.ClassNotFoundException: org.apache.maven.plugin.MojoFailureException
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    ... 75 more
+3  A: 
Robert Munteanu
Thanks for the suggestion - I have tried this and it made no difference.
Simon Nickerson
Have you tried turning workspace resolution off ? You will then build each project based on the artifacts already installed in your repository.
Robert Munteanu
+3  A: 

The resource filtering mentioned in the FAQ is run whenever the Maven builder is run on the project. In practice I've found this to be more trouble than it's worth as the Maven builder runs quite slowly, and is only run when configured (which by default is only on a full build), leaving you to scratch your head and wonder why your changes aren't picked up.

I tend to modify the Eclipse classpath to include src/main/resources. This is sufficient for most use cases.

For the cases where the simple approach doesn't work (for example if a dependent project has some complicated resource processing), I do as Robert suggests and turn off workspace resolution, then install the dependency to the local repository so it is included in the Maven classpath container.

Rich Seller