我有一个简单的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的类路径?
我已经将Groovy放置在 /usr/local/opt/groovy/libexec/
下。
testCompile
替换为testImplementation
:"在Gradle 7+中,已移除compile和testCompile配置。您可以使用implementation和testImplementation代替。" (https://intellij-support.jetbrains.com/hc/en-us/community/posts/4403048541330-Could-not-find-method-testCompile-for-arguments-group-junit-name-junit-version-4-12-on-object-of-type-org-gradle-api-internal-artifacts-dsl-dependencies-DefaultDependencyHandler-) - bshacklett