为什么m2eclipse会从Eclipse构建路径中排除资源?

时间:2009-08-06 08:07:49

标签: java eclipse maven-2 m2eclipse

我正在尝试使用Maven的Eclipse插件m2eclipse,并注意到资源现在已从我所有项目的构建路径中排除。

我看到a question on the M2Eclipse FAQ page似乎处理了这个确切的问题,但答案(解释)似乎说这是为了允许资源过滤,一切都应该正常工作。

但是,当我从Eclipse中运行我的应用程序时,依赖项目中的大量资源无法被我的应用程序找到。

我尝试过我常用的Eclipse挥动 - 橡胶 - 鸡肉行动(清洁所有项目,从-clean开始)无济于事。我敢肯定我错过了一些相当简单的东西。有没有人有任何建议?

编辑:m2控制台中的一些挖掘显示其中一个项目未正确构建。当我试图在用于构建其中一个项目的自定义插件中找到ClassNotFoundException时,我得到org.apache.maven.plugin.MojoFailureException

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

2 个答案:

答案 0 :(得分:5)

只要在项目上运行Maven构建器,就会运行FAQ中提到的资源过滤。在实践中,我发现这比它的价值更麻烦,因为Maven构建器运行速度非常慢,并且仅在配置时运行(默认情况下仅在完整版本上运行),让你抓住头脑并想知道为什么你的没有接受更改。

我倾向于修改Eclipse类路径以包含src / main / resources。这对于大多数用例来说已经足够了。

对于简单方法不起作用的情况(例如,如果依赖项目有一些复杂的资源处理),我按照罗伯特建议并关闭工作区解析,然后将依赖项安装到本地存储库,因此它是包含在Maven类路径容器中。

答案 1 :(得分:3)

尝试在嵌入式(3.0 AFAIK)Maven运行时和用于执行构建(本地安装)的运行时之间切换。

Maven installations http://img150.imageshack.us/img150/6193/m2eclipseinstallations.png