gpt4 book ai didi

gradle - 使用gradle时无法推断groovy类路径

转载 作者:行者123 更新时间:2023-12-04 03:14:25 29 4
gpt4 key购买 nike

我有一个琐碎的Gradle项目:

apply plugin: 'groovy'
apply plugin: 'application'

mainClassName = 'HelloWorld'

使用 src/main/groovy中的一个Groovy源文件:
public class HelloWorld {
public static void main(String[] args) {
print "hello world"
}
}

我键入 gradle run并收到以下错误:
FAILURE: Build failed with an exception.

* What went wrong:
Cannot infer Groovy class path because no Groovy Jar was found on class path: [/Users/jzwolak/files/experimenting/gradle/groovy-project/build/classes/java/main]

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

BUILD FAILED in 0s
1 actionable task: 1 executed

如何为Gradle配置Groovy类路径?

我在 /usr/local/opt/groovy/libexec/上有Groovy

最佳答案

您需要声明一个常规的依赖项,如文档https://docs.gradle.org/current/userguide/groovy_plugin.html#sec:groovy_dependency_management中所示

repositories {
mavenCentral()
}

dependencies {
compile 'org.codehaus.groovy:groovy-all:2.4.14'
}

关于gradle - 使用gradle时无法推断groovy类路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49120352/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com