我正在尝试使用 Gradle 进行基本构建。甚至gradle -v
因以下原因失败:
$ gradle -v
FAILURE: Build aborted because of an internal error.
* What went wrong:
Build aborted because of an unexpected internal error. Please file an issue at: http://www.gradle.org.
* Try:
Run with --debug option to get additional debug info.
* Exception is:
java.lang.NoClassDefFoundError: groovy/lang/GroovySystem
at org.gradle.util.GradleVersion.prettyPrint(GradleVersion.java:183)
at org.gradle.launcher.CommandLineActionFactory$ShowVersionAction.run(CommandLineActionFactory.java:181)
at org.gradle.launcher.CommandLineActionFactory$ActionAdapter.execute(CommandLineActionFactory.java:199)
at org.gradle.launcher.CommandLineActionFactory$ActionAdapter.execute(CommandLineActionFactory.java:191)
(stacktrace snipped)
at org.gradle.launcher.ProcessBootstrap.run(ProcessBootstrap.java:28)
at org.gradle.launcher.GradleMain.main(GradleMain.java:24)
Caused by: java.lang.ClassNotFoundException: groovy.lang.GroovySystem
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
... 17 more
所以,我想“啊哈,我的类路径是空的。让我添加 groovy”。
$ export CLASSPATH=/usr/share/gradle/lib/groovy-all.jar && echo $CLASSPATH
/usr/share/gradle/lib/groovy-all.jar
没有不同。
对于它的价值,这里是 build.gradle:
apply plugin: 'eclipse'
apply plugin: 'groovy'
repositories {
mavenCentral()
}
dependencies {
groovy group: 'org.codehaus.groovy', name: 'groovy', version: '1.7.10'
testCompile group: 'junit', name: 'junit', version: '4.8.2'
}
我发现的唯一相关的 stackoverflow 问题是this,而 google 也好不到哪里去。
gradle的安装文档说“Gradle 带有自己的 Groovy 库,因此不需要安装 Groovy。” 这意味着类路径是不必要的。那为什么我不能运行呢?