使用groovy-eclipse-plugin和@Grab时出错

时间:2015-07-01 21:28:53

标签: maven groovy grape

在新系统上运行mvn clean compile时出现以下错误。它在我的本地(windows)环境中工作正常。

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project visa-threatintel: Compilation failure: Compilation failure:
[ERROR] /path/to/Class.groovy:[2,2] 1. ERROR in /path/to/Class.groovy (at line 2)
[ERROR] @Grab(group="javax.mail", module="mail", version="1.5.0-b01", type="jar"),
[ERROR] ^^^
[ERROR] Groovy:Ambiguous method overloading for method org.apache.ivy.core.settings.IvySettings#load.

本地和新系统都使用Maven 3.2.5并且POM是相同的。相关摘录如下:

<groovy.version>2.2.1</groovy.version>
<ivy.version>2.4.0</ivy.version>


 <build>
    <plugins>
            <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.1</version>
                    <extensions>true</extensions>
                    <configuration>
                            <!-- http://maven.apache.org/plugins/maven-compiler-plugin/ -->
                            <source>1.6</source>
                            <target>1.6</target>
                            <compilerId>groovy-eclipse-compiler</compilerId>
                    </configuration>
                    <dependencies>
                            <dependency>
                                    <groupId>org.codehaus.groovy</groupId>
                                    <artifactId>groovy-eclipse-compiler</artifactId>
                                    <version>2.9.0-01</version>
                            </dependency>
                            <!-- 2.2.1 version isn't available as a release, so it needs to be acquired
                                    from the codehaus nexus repository -->
                            <dependency>
                                    <groupId>org.codehaus.groovy</groupId>
                                    <artifactId>groovy-eclipse-batch</artifactId>
                                    <version>${groovy.version}-01-SNAPSHOT</version>
                            </dependency>
                            <!-- to allow @Grab annotations -->
                            <dependency>
                                    <groupId>org.apache.ivy</groupId>
                                    <artifactId>ivy</artifactId>
                                    <version>${ivy.version}</version>
                            </dependency>
                    </dependencies>
            </plugin>
            <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>build-helper-maven-plugin</artifactId>
                    <version>1.9.1</version>
                    <executions>
                            <execution>
                                    <id>add-source</id>
                                    <phase>generate-sources</phase>
                                    <goals>
                                            <goal>add-source</goal>
                                    </goals>
                                    <configuration>
                                            <sources>
                                                    <source>src/main/groovy</source>
                                            </sources>
                                    </configuration>
                            </execution>

我尝试将groovy版本更改为2.4.3,但得到了同样的错误。以前有人见过这样的事吗?

1 个答案:

答案 0 :(得分:1)

刚刚遇到类似的问题,我发现我有两个问题:

未能下载的Maven deps

maven依赖(maven-assembly-plugin)下载失败。

删除本地m2存储库中的.lastUpdated文件:

#> find ~/.m2/repository -name *.lastUpdated
~/.m2/repository/org/apache/maven/plugins/maven-assembly-plugin/2.2-beta-5/maven-assembly-plugin-2.2-beta-5.pom.lastUpdated

#> find ~/.m2/repository -name *.lastUpdated -delete

grapeConfig.xml&amp;存储库ssl证书

此外,您的~/.groovy/grapeConfig.xml文件需要配置为告诉groovy从何处提取依赖项 - 在我的情况下,它来自公司nexus存储库,这也意味着我必须在JRE cacerts中安装https证书文件。

如何测试

测试你的一个建议是正确设置所有内容就是在测试依赖项上调用grape install,这样可以更清楚地了解错误(葡萄作为常规二进制文件的一部分分发,所以把它包括在你的路径上,或完全限定它的路径):

grape install javax.mail mail 1.5.0-b01
相关问题