使用gradle时无法推断groovy类路径 [英] Cannot infer groovy classpath when using gradle
本文介绍了使用gradle时无法推断groovy类路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个琐碎的Gradle项目:
I have a trivial Gradle project:
apply plugin: 'groovy'
apply plugin: 'application'
mainClassName = 'HelloWorld'
在src/main/groovy
中具有一个Groovy源文件:
With one Groovy source file in src/main/groovy
:
public class HelloWorld {
public static void main(String[] args) {
print "hello world"
}
}
我键入gradle run
并得到以下错误:
I type gradle run
and get the following error:
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类路径?
How do I configure the Groovy classpath for Gradle?
我在/usr/local/opt/groovy/libexec/
上有Groovy
I have Groovy at /usr/local/opt/groovy/libexec/
推荐答案
You need to declare a groovy dependency, as in the documentation 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时无法推断groovy类路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文