Maven 编译混合 Java + Groovy 1.7 项目,使用 gmaven-plugin
根据以下两个答案:maven dependency groovy。我正在尝试使用 org.codehaus.gmaven 中的 GMaven 插件,使用 Maven 编译一个混合的 Java 6 + Groovy 项目。直到昨天,我们还在使用旧的 1.6.0
版本的 Groovy(在我们最终让它工作后从未更改过它),但由于 1.7.0
现在已经稳定了,我想我们会转向那个。
如果事情这么简单就好了。我现在遇到的问题似乎有两个方面:
Groovy 1.6
不知何故仍然被选为默认值。 (如下面的堆栈跟踪所示)- groovy:generateStubs 因构建错误而停止:意外的节点:Node[7:1,64,ANNOTATIONS]
有谁知道如何解决上述两个问题,或者可以提供一个工作pom来编译< code>Java 6 代码与带有 Maven 的 Groovy 1.7
代码混合?
有很多关于使用 gmaven / groovy.maven / groovy.maven.gmaven 编译旧版本 Groovy 的令人困惑/矛盾/过时的文档,这些文档现在确实没有帮助
。 Maven -e 输出:
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>1.7.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.2</version>
<dependencies>
<dependency>
<groupId>org.codehaus.gmaven.runtime</groupId>
<artifactId>gmaven-runtime-1.7</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>1.7.0</version>
</dependency>
</dependencies>
<executions>
<execution>
<goals>
<goal>generateStubs</goal>
<goal>compile</goal>
<goal>generateTestStubs</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
堆栈跟踪:
[INFO] ------------------------------------------------------------------------
[INFO] Building Client
[INFO] task-segment: [clean, package]
[INFO] ------------------------------------------------------------------------
[INFO] [clean:clean {execution: default-clean}]
[INFO] [groovy:generateStubs {execution: default}]
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Unexpected node: Node[7:1,64,ANNOTATIONS]
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Unexpected node: Node[7:1,64,ANNOTATIONS]
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: Unexpected node: Node[7:1,64,ANNOTATIONS]
at org.codehaus.gmaven.plugin.MojoSupport.execute(MojoSupport.java:85)
at org.codehaus.gmaven.plugin.stubgen.AbstractGenerateStubsMojo.execute(AbstractGenerateStubsMojo.java:60)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
... 17 more
Caused by: org.codehaus.gmaven.runtime.support.stubgen.UnexpectedNodeException: Unexpected node: Node[7:1,64,ANNOTATIONS]
at org.codehaus.gmaven.runtime.support.stubgen.parser.NodeSupport.ensure(NodeSupport.java:96)
at org.codehaus.gmaven.runtime.support.stubgen.model.ModelFactorySupport.identifier(ModelFactorySupport.java:896)
at org.codehaus.gmaven.runtime.support.stubgen.model.ModelFactorySupport.importDef(ModelFactorySupport.java:185)
at org.codehaus.gmaven.runtime.support.stubgen.model.ModelFactorySupport.process(ModelFactorySupport.java:122)
at org.codehaus.gmaven.runtime.support.stubgen.model.ModelFactorySupport.create(ModelFactorySupport.java:90)
at org.codehaus.gmaven.runtime.support.stubgen.model.ModelFactorySupport.create(ModelFactorySupport.java:61)
at org.codehaus.gmaven.runtime.v1_6.StubCompilerFeature$StubCompilerImpl.render(StubCompilerFeature.java:101)
at org.codehaus.gmaven.runtime.v1_6.StubCompilerFeature$StubCompilerImpl.compile(StubCompilerFeature.java:90)
at org.codehaus.gmaven.plugin.stubgen.AbstractGenerateStubsMojo.compile(AbstractGenerateStubsMojo.java:160)
at org.codehaus.gmaven.plugin.stubgen.AbstractGenerateStubsMojo.process(AbstractGenerateStubsMojo.java:131)
at org.codehaus.gmaven.plugin.ComponentMojoSupport.doExecute(ComponentMojoSupport.java:60)
at org.codehaus.gmaven.plugin.MojoSupport.execute(MojoSupport.java:69)
... 20 more
As per the top two answers in: maven dependencies groovy. I'm trying to compile a mixed Java 6 + Groovy project with Maven, using the GMaven-plugin from org.codehaus.gmaven. Up until yesterday we were using the old 1.6.0
version of Groovy (never changed it after we finally got it working), but since 1.7.0
is now stable I thought we'd switch to that.
If only things were that simple.. The problems I'm now encountering seem to be two fold:
Groovy 1.6
is somehow still picked up as the default. (as show in the stacktrace below)- groovy:generateStubs stops with a build error: Unexpected node: Node[7:1,64,ANNOTATIONS]
Does anyone know how to solve the above two problems, or can provide a working pom to compile Java 6
code intermixed with Groovy 1.7
code with Maven?
There's a lot of confusing / contradicting / outdated documentation on compiling old versions of Groovy using gmaven / groovy.maven / groovy.maven.gmaven that's really not helping things right now..
For reference, here's part of my pom.xml & the Maven -e output:
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>1.7.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.2</version>
<dependencies>
<dependency>
<groupId>org.codehaus.gmaven.runtime</groupId>
<artifactId>gmaven-runtime-1.7</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>1.7.0</version>
</dependency>
</dependencies>
<executions>
<execution>
<goals>
<goal>generateStubs</goal>
<goal>compile</goal>
<goal>generateTestStubs</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Stacktrace:
[INFO] ------------------------------------------------------------------------
[INFO] Building Client
[INFO] task-segment: [clean, package]
[INFO] ------------------------------------------------------------------------
[INFO] [clean:clean {execution: default-clean}]
[INFO] [groovy:generateStubs {execution: default}]
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Unexpected node: Node[7:1,64,ANNOTATIONS]
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Unexpected node: Node[7:1,64,ANNOTATIONS]
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: Unexpected node: Node[7:1,64,ANNOTATIONS]
at org.codehaus.gmaven.plugin.MojoSupport.execute(MojoSupport.java:85)
at org.codehaus.gmaven.plugin.stubgen.AbstractGenerateStubsMojo.execute(AbstractGenerateStubsMojo.java:60)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
... 17 more
Caused by: org.codehaus.gmaven.runtime.support.stubgen.UnexpectedNodeException: Unexpected node: Node[7:1,64,ANNOTATIONS]
at org.codehaus.gmaven.runtime.support.stubgen.parser.NodeSupport.ensure(NodeSupport.java:96)
at org.codehaus.gmaven.runtime.support.stubgen.model.ModelFactorySupport.identifier(ModelFactorySupport.java:896)
at org.codehaus.gmaven.runtime.support.stubgen.model.ModelFactorySupport.importDef(ModelFactorySupport.java:185)
at org.codehaus.gmaven.runtime.support.stubgen.model.ModelFactorySupport.process(ModelFactorySupport.java:122)
at org.codehaus.gmaven.runtime.support.stubgen.model.ModelFactorySupport.create(ModelFactorySupport.java:90)
at org.codehaus.gmaven.runtime.support.stubgen.model.ModelFactorySupport.create(ModelFactorySupport.java:61)
at org.codehaus.gmaven.runtime.v1_6.StubCompilerFeature$StubCompilerImpl.render(StubCompilerFeature.java:101)
at org.codehaus.gmaven.runtime.v1_6.StubCompilerFeature$StubCompilerImpl.compile(StubCompilerFeature.java:90)
at org.codehaus.gmaven.plugin.stubgen.AbstractGenerateStubsMojo.compile(AbstractGenerateStubsMojo.java:160)
at org.codehaus.gmaven.plugin.stubgen.AbstractGenerateStubsMojo.process(AbstractGenerateStubsMojo.java:131)
at org.codehaus.gmaven.plugin.ComponentMojoSupport.doExecute(ComponentMojoSupport.java:60)
at org.codehaus.gmaven.plugin.MojoSupport.execute(MojoSupport.java:69)
... 20 more
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我也有同样的问题。我缺少 1.7 的providerSelection 配置设置。
尝试这个配置,它应该适合您。
I had the same problem. I was missing the providerSelection configuration setting for 1.7.
Try this configuration and it should work for you.
这对我来说也很有效,只需添加一点:
也许有一种方法可以使其成为默认值?
That works for me as well with one small addition:
Maybe there is a way to make this the default?
看到这篇文章,它帮助我编译了java和groovy
Groovy Java 一起编译
See this article, it helped me to compile both java and groovy
Groovy Java compile together