我有一个简单的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/
答案 0 :(得分:8)
您需要声明一个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'
}