Groovy版本不匹配在Eclipse中的Gradle项目中运行spock测试

时间:2015-03-05 16:21:37

标签: eclipse groovy gradle spock eclipse-kepler

我在Eclipse Kepler中有一个带有几个类和一个Spock规范的Groovy和Gradle项目。我可以从shell运行Gradle构建,它工作正常,包括Spock规范。

我现在想尝试在Eclipse中运行Spock规范,无论是否在调试器中。当我运行它时,我看到以下内容:

Conflicting module versions. Module [groovy-all is loaded in version 2.3.9 and
you are trying to load version 2.3.10

这是我的"依赖"来自build.gradle的块:

dependencies {
    compile localGroovy()
    compile gradleApi()
    compile "org.opendaylight.yangtools:yang-parser-impl:0.7.0-SNAPSHOT"
    testCompile("org.spockframework:spock-core:1.0-groovy-2.3") {
        exclude group: "org.codehaus.groovy"
    }
}

我可以在Project Explorer中看到我的Gradle依赖项有groovy-all-2.3.9.jar,我的Groovy依赖项有groovy-all-2.3.10.jar。

这有点乱。我可以安全地编辑项目的Groovy依赖项并将jar更改为2.3.9版本吗?

更新

这是什么" groovy依赖"从命令行说。这与Eclipse正在使用的内容无关。

:dependencies

------------------------------------------------------------
Root project
------------------------------------------------------------

archives - Configuration for archive artifacts.
No dependencies

compile - Compile classpath for source set 'main'.
+--- org.codehaus.groovy:groovy-all:2.3.9
\--- org.opendaylight.yangtools:yang-parser-impl:0.7.0-SNAPSHOT
 +--- org.opendaylight.yangtools:yang-common:0.7.0-SNAPSHOT
 |    +--- com.google.guava:guava:18.0
 |    +--- org.slf4j:slf4j-api:1.7.2
 |    +--- org.opendaylight.yangtools:concepts:0.7.0-SNAPSHOT
 |    \--- org.opendaylight.yangtools:object-cache-api:0.7.0-SNAPSHOT
 |         +--- org.opendaylight.yangtools:concepts:0.7.0-SNAPSHOT
 |         +--- org.slf4j:slf4j-api:1.7.2
 |         \--- com.google.guava:guava:18.0
 +--- org.opendaylight.yangtools:yang-model-api:0.7.0-SNAPSHOT
 |    +--- org.opendaylight.yangtools:object-cache-api:0.7.0-SNAPSHOT (*)
 |    +--- org.opendaylight.yangtools:util:0.7.0-SNAPSHOT
 |    |    +--- org.opendaylight.yangtools:concepts:0.7.0-SNAPSHOT
 |    |    +--- com.google.code.findbugs:jsr305:2.0.3
 |    |    +--- org.slf4j:slf4j-api:1.7.2
 |    |    +--- com.google.guava:guava:18.0
 |    |    \--- com.github.romix:java-concurrent-hash-trie-map:0.2.23
 |    +--- org.opendaylight.yangtools:yang-common:0.7.0-SNAPSHOT (*)
 |    +--- com.google.guava:guava:18.0
 |    \--- com.google.code.findbugs:jsr305:2.0.3
 +--- org.opendaylight.yangtools:yang-parser-api:0.7.0-SNAPSHOT
 |    \--- org.opendaylight.yangtools:yang-model-api:0.7.0-SNAPSHOT (*)
 +--- org.opendaylight.yangtools:yang-model-util:0.7.0-SNAPSHOT
 |    \--- org.opendaylight.yangtools:yang-model-api:0.7.0-SNAPSHOT (*)
 +--- org.antlr:antlr4-runtime:4.0
 |    \--- org.abego.treelayout:org.abego.treelayout.core:1.0.1
 +--- com.google.guava:guava:18.0
 +--- org.opendaylight.yangtools:concepts:0.7.0-SNAPSHOT
 +--- commons-io:commons-io:2.4
 \--- com.google.code.findbugs:jsr305:2.0.3

default - Configuration for default artifacts.
+--- org.codehaus.groovy:groovy-all:2.3.9
\--- org.opendaylight.yangtools:yang-parser-impl:0.7.0-SNAPSHOT
 +--- org.opendaylight.yangtools:yang-common:0.7.0-SNAPSHOT
 |    +--- com.google.guava:guava:18.0
 |    +--- org.slf4j:slf4j-api:1.7.2
 |    +--- org.opendaylight.yangtools:concepts:0.7.0-SNAPSHOT
 |    \--- org.opendaylight.yangtools:object-cache-api:0.7.0-SNAPSHOT
 |         +--- org.opendaylight.yangtools:concepts:0.7.0-SNAPSHOT
 |         +--- org.slf4j:slf4j-api:1.7.2
 |         \--- com.google.guava:guava:18.0
 +--- org.opendaylight.yangtools:yang-model-api:0.7.0-SNAPSHOT
 |    +--- org.opendaylight.yangtools:object-cache-api:0.7.0-SNAPSHOT (*)
 |    +--- org.opendaylight.yangtools:util:0.7.0-SNAPSHOT
 |    |    +--- org.opendaylight.yangtools:concepts:0.7.0-SNAPSHOT
 |    |    +--- com.google.code.findbugs:jsr305:2.0.3
 |    |    +--- org.slf4j:slf4j-api:1.7.2
 |    |    +--- com.google.guava:guava:18.0
 |    |    \--- com.github.romix:java-concurrent-hash-trie-map:0.2.23
 |    +--- org.opendaylight.yangtools:yang-common:0.7.0-SNAPSHOT (*)
 |    +--- com.google.guava:guava:18.0
 |    \--- com.google.code.findbugs:jsr305:2.0.3
 +--- org.opendaylight.yangtools:yang-parser-api:0.7.0-SNAPSHOT
 |    \--- org.opendaylight.yangtools:yang-model-api:0.7.0-SNAPSHOT (*)
 +--- org.opendaylight.yangtools:yang-model-util:0.7.0-SNAPSHOT
 |    \--- org.opendaylight.yangtools:yang-model-api:0.7.0-SNAPSHOT (*)
 +--- org.antlr:antlr4-runtime:4.0
 |    \--- org.abego.treelayout:org.abego.treelayout.core:1.0.1
 +--- com.google.guava:guava:18.0
 +--- org.opendaylight.yangtools:concepts:0.7.0-SNAPSHOT
 +--- commons-io:commons-io:2.4
 \--- com.google.code.findbugs:jsr305:2.0.3

runtime - Runtime classpath for source set 'main'.
+--- org.codehaus.groovy:groovy-all:2.3.9
\--- org.opendaylight.yangtools:yang-parser-impl:0.7.0-SNAPSHOT
 +--- org.opendaylight.yangtools:yang-common:0.7.0-SNAPSHOT
 |    +--- com.google.guava:guava:18.0
 |    +--- org.slf4j:slf4j-api:1.7.2
 |    +--- org.opendaylight.yangtools:concepts:0.7.0-SNAPSHOT
 |    \--- org.opendaylight.yangtools:object-cache-api:0.7.0-SNAPSHOT
 |         +--- org.opendaylight.yangtools:concepts:0.7.0-SNAPSHOT
 |         +--- org.slf4j:slf4j-api:1.7.2
 |         \--- com.google.guava:guava:18.0
 +--- org.opendaylight.yangtools:yang-model-api:0.7.0-SNAPSHOT
 |    +--- org.opendaylight.yangtools:object-cache-api:0.7.0-SNAPSHOT (*)
 |    +--- org.opendaylight.yangtools:util:0.7.0-SNAPSHOT
 |    |    +--- org.opendaylight.yangtools:concepts:0.7.0-SNAPSHOT
 |    |    +--- com.google.code.findbugs:jsr305:2.0.3
 |    |    +--- org.slf4j:slf4j-api:1.7.2
 |    |    +--- com.google.guava:guava:18.0
 |    |    \--- com.github.romix:java-concurrent-hash-trie-map:0.2.23
 |    +--- org.opendaylight.yangtools:yang-common:0.7.0-SNAPSHOT (*)
 |    +--- com.google.guava:guava:18.0
 |    \--- com.google.code.findbugs:jsr305:2.0.3
 +--- org.opendaylight.yangtools:yang-parser-api:0.7.0-SNAPSHOT
 |    \--- org.opendaylight.yangtools:yang-model-api:0.7.0-SNAPSHOT (*)
 +--- org.opendaylight.yangtools:yang-model-util:0.7.0-SNAPSHOT
 |    \--- org.opendaylight.yangtools:yang-model-api:0.7.0-SNAPSHOT (*)
 +--- org.antlr:antlr4-runtime:4.0
 |    \--- org.abego.treelayout:org.abego.treelayout.core:1.0.1
 +--- com.google.guava:guava:18.0
 +--- org.opendaylight.yangtools:concepts:0.7.0-SNAPSHOT
 +--- commons-io:commons-io:2.4
 \--- com.google.code.findbugs:jsr305:2.0.3

testCompile - Compile classpath for source set 'test'.
+--- org.codehaus.groovy:groovy-all:2.3.9
+--- org.opendaylight.yangtools:yang-parser-impl:0.7.0-SNAPSHOT
|    +--- org.opendaylight.yangtools:yang-common:0.7.0-SNAPSHOT
|    |    +--- com.google.guava:guava:18.0
|    |    +--- org.slf4j:slf4j-api:1.7.2
|    |    +--- org.opendaylight.yangtools:concepts:0.7.0-SNAPSHOT
|    |    \--- org.opendaylight.yangtools:object-cache-api:0.7.0-SNAPSHOT
|    |         +--- org.opendaylight.yangtools:concepts:0.7.0-SNAPSHOT
|    |         +--- org.slf4j:slf4j-api:1.7.2
|    |         \--- com.google.guava:guava:18.0
|    +--- org.opendaylight.yangtools:yang-model-api:0.7.0-SNAPSHOT
|    |    +--- org.opendaylight.yangtools:object-cache-api:0.7.0-SNAPSHOT (*)
|    |    +--- org.opendaylight.yangtools:util:0.7.0-SNAPSHOT
|    |    |    +--- org.opendaylight.yangtools:concepts:0.7.0-SNAPSHOT
|    |    |    +--- com.google.code.findbugs:jsr305:2.0.3
|    |    |    +--- org.slf4j:slf4j-api:1.7.2
|    |    |    +--- com.google.guava:guava:18.0
|    |    |    \--- com.github.romix:java-concurrent-hash-trie-map:0.2.23
|    |    +--- org.opendaylight.yangtools:yang-common:0.7.0-SNAPSHOT (*)
|    |    +--- com.google.guava:guava:18.0
|    |    \--- com.google.code.findbugs:jsr305:2.0.3
|    +--- org.opendaylight.yangtools:yang-parser-api:0.7.0-SNAPSHOT
|    |    \--- org.opendaylight.yangtools:yang-model-api:0.7.0-SNAPSHOT (*)
|    +--- org.opendaylight.yangtools:yang-model-util:0.7.0-SNAPSHOT
|    |    \--- org.opendaylight.yangtools:yang-model-api:0.7.0-SNAPSHOT (*)
|    +--- org.antlr:antlr4-runtime:4.0
|    |    \--- org.abego.treelayout:org.abego.treelayout.core:1.0.1
|    +--- com.google.guava:guava:18.0
|    +--- org.opendaylight.yangtools:concepts:0.7.0-SNAPSHOT
|    +--- commons-io:commons-io:2.4
|    \--- com.google.code.findbugs:jsr305:2.0.3
\--- org.spockframework:spock-core:1.0-groovy-2.3
 \--- junit:junit:4.12
      \--- org.hamcrest:hamcrest-core:1.3

testRuntime - Runtime classpath for source set 'test'.
+--- org.codehaus.groovy:groovy-all:2.3.9
+--- org.opendaylight.yangtools:yang-parser-impl:0.7.0-SNAPSHOT
|    +--- org.opendaylight.yangtools:yang-common:0.7.0-SNAPSHOT
|    |    +--- com.google.guava:guava:18.0
|    |    +--- org.slf4j:slf4j-api:1.7.2
|    |    +--- org.opendaylight.yangtools:concepts:0.7.0-SNAPSHOT
|    |    \--- org.opendaylight.yangtools:object-cache-api:0.7.0-SNAPSHOT
|    |         +--- org.opendaylight.yangtools:concepts:0.7.0-SNAPSHOT
|    |         +--- org.slf4j:slf4j-api:1.7.2
|    |         \--- com.google.guava:guava:18.0
|    +--- org.opendaylight.yangtools:yang-model-api:0.7.0-SNAPSHOT
|    |    +--- org.opendaylight.yangtools:object-cache-api:0.7.0-SNAPSHOT (*)
|    |    +--- org.opendaylight.yangtools:util:0.7.0-SNAPSHOT
|    |    |    +--- org.opendaylight.yangtools:concepts:0.7.0-SNAPSHOT
|    |    |    +--- com.google.code.findbugs:jsr305:2.0.3
|    |    |    +--- org.slf4j:slf4j-api:1.7.2
|    |    |    +--- com.google.guava:guava:18.0
|    |    |    \--- com.github.romix:java-concurrent-hash-trie-map:0.2.23
|    |    +--- org.opendaylight.yangtools:yang-common:0.7.0-SNAPSHOT (*)
|    |    +--- com.google.guava:guava:18.0
|    |    \--- com.google.code.findbugs:jsr305:2.0.3
|    +--- org.opendaylight.yangtools:yang-parser-api:0.7.0-SNAPSHOT
|    |    \--- org.opendaylight.yangtools:yang-model-api:0.7.0-SNAPSHOT (*)
|    +--- org.opendaylight.yangtools:yang-model-util:0.7.0-SNAPSHOT
|    |    \--- org.opendaylight.yangtools:yang-model-api:0.7.0-SNAPSHOT (*)
|    +--- org.antlr:antlr4-runtime:4.0
|    |    \--- org.abego.treelayout:org.abego.treelayout.core:1.0.1
|    +--- com.google.guava:guava:18.0
|    +--- org.opendaylight.yangtools:concepts:0.7.0-SNAPSHOT
|    +--- commons-io:commons-io:2.4
|    \--- com.google.code.findbugs:jsr305:2.0.3
\--- org.spockframework:spock-core:1.0-groovy-2.3
 \--- junit:junit:4.12
      \--- org.hamcrest:hamcrest-core:1.3

(*) - dependencies omitted (listed previously)

BUILD SUCCESSFUL

Total time: 2.041 secs

2 个答案:

答案 0 :(得分:4)

当使用kepler和gradle时,每个人都将其groovy模块放在类路径上。让我们不要使用kepler的: enter image description here

答案 1 :(得分:0)

我建议使用下面的依赖项而不是localGroovy(),以避免团队成员遇到麻烦。让依赖关系管理工作为gradle

compile "org.codehaus.groovy:groovy-all:2.3.9"

修改01 检查此链接,以便切换de groovy版本 http://groovy.codehaus.org/Compiler+Switching+within+Groovy-Eclipse