Gradle 找不到 org.codehaus.groovy:groovy:4.0.12

问题描述 投票:0回答:1

我必须删除我的项目并重新创建它,当我这样做时,我开始从我的 gradle 构建中收到以下错误。

Starting a Gradle Daemon (subsequent builds will be faster)

> Task :compileJava
Note: /home/thomas/workspace/util/src/main/java/com/heavyweightsoftware/util/EasyXmlParser.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

> Task :compileTestGroovy FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileTestGroovy'.
> Could not resolve all files for configuration ':detachedConfiguration1'.
   > Could not find org.codehaus.groovy:groovy:4.0.12.
     Searched in the following locations:
       - https://repo.maven.apache.org/maven2/org/codehaus/groovy/groovy/4.0.12/groovy-4.0.12.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project :
   > Could not find org.codehaus.groovy:groovy-ant:4.0.12.
     Searched in the following locations:
       - https://repo.maven.apache.org/maven2/org/codehaus/groovy/groovy-ant/4.0.12/groovy-ant-4.0.12.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project :
   > Could not find org.codehaus.groovy:groovy-templates:4.0.12.
     Searched in the following locations:
       - https://repo.maven.apache.org/maven2/org/codehaus/groovy/groovy-templates/4.0.12/groovy-templates-4.0.12.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project :

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.6.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 5s
3 actionable tasks: 3 executed

Google 错误并没有发现任何内容...这是我的 gradle 构建的有用部分。

plugins {
    id 'groovy'
    id 'java'
}

...

apply plugin: 'groovy'
apply plugin: 'java'

...

dependencies {
    implementation (
            'org.apache.groovy:groovy-all:4.0.12',
            'jakarta.xml.bind:jakarta.xml.bind-api:4.0.0',
    )

    testImplementation (
            'org.junit.jupiter:junit-jupiter-api:5.8.1',
            'org.spockframework:spock-core:2.4-M1-groovy-4.0',
            'io.github.joke:spock-mockable:2.3.1',
            'cglib:cglib-nodep:3.3.0'
    )

    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
}

...

test {
    useJUnitPlatform()
}

我只使用 groovy 对我的 java 类进行 spock 测试。

有人发现有什么问题吗?

gradle groovy spock
1个回答
0
投票

如果您查看 Gradle 7.5 的发行说明,您会发现该版本添加了编译 Groovy 4 代码的功能。

从构建的输出中可以看到,您的 Gradle 版本是 6.6.1。

因此您的 Gradle 版本太旧,无法构建 Groovy 4 代码。

如果你想使用Groovy 4,你需要将Gradle更新到至少7.5。

© www.soinside.com 2019 - 2024. All rights reserved.