加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

使用@Grab注释编译Groovy项目时出错

发布时间:2020-12-14 16:35:17 所属栏目:大数据 来源:网络整理
导读:我正在用Gradle编译一个Groovy项目,但是我注意到,当我在代码中使用@Grab注释时,我会收到以下错误: $gradle compile:buildInfo:compileJava UP-TO-DATE:compileGroovy FAILEDFAILURE: Build failed with an exception.* What went wrong:Execution failed fo
我正在用Gradle编译一个Groovy项目,但是我注意到,当我在代码中使用@Grab注释时,我会收到以下错误:

$gradle compile
:buildInfo
:compileJava UP-TO-DATE
:compileGroovy FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileGroovy'.
> org/apache/ivy/core/report/ResolveReport

(全栈跟踪这里http://pastebin.com/0ty4jNct)

我发现唯一的办法就是把groovy和ivy模块添加到groovy类路径,但是我想避免这种情况,因为groovy类路径被弃用.

这是一个Gradle bug吗?还是有更好的方式来管理@Grab依赖关系?

解决方法

@Grab旨在用于未预编译的独立脚本,并且通常不会将其与已编译的代码一起使用.如果你这样做,你可能需要添加Ivy来groovyClasspath.就像是:

repositories {
    mavenCentral()
}

configurations {
    ivy
}

dependencies {
    ivy "org.apache.ivy:ivy:2.3.0"
    compile "org.codehaus.groovy:groovy-all:2.1.5"
}  

tasks.withType(GroovyCompile) {
    groovyClasspath += configurations.ivy
}

也就是说,更好的方法是管理与Gradle的依赖关系.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读