grditタスクを実行しようとすると、GradleがNoClassDefFoundErrorをスローします。grgit NoClassDefFoundError
build.gradle
のスタート:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'org.ajoberstar:gradle-git:1.2.0'
}
}
apply plugin: 'com.android.application'
//
//
import org.ajoberstar.grgit.*
task clone << {
File dir = new File('contrib/otherstuff')
if(!dir.exists()) {
def grgit = Grgit.clone(dir: dir, uri: 'https://github.com/someguy/otherstuff.git')
}
// TODO else (pull)
}
project.afterEvaluate {
preBuild.dependsOn clone
}
// rest omitted
出力:
Relying on packaging to define the extension of the main artifact has been deprecated and is scheduled to be removed in Gradle 2.0
:src:myproject:clone FAILED
FAILURE: Build failed with an exception.
* Where:
Build file '/home/me/src/myproject/build.gradle' line: 20
* What went wrong:
Execution failed for task ':src:myproject:clone'.
> java.lang.NoClassDefFoundError: org/codehaus/groovy/runtime/typehandling/ShortTypeHandling
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 16.937 secs
ライン20はGrgit.clone()
への呼び出しです。
ビルド依存関係(エラーメッセージが示すようなもの)としてgroovyを追加する必要がありますか?どのように追加すればいいですか?
EDIT:gradleバージョンが重要な場合1.10です。
'apply plugin: 'groovy''を見逃しましたか? – Rao
'apply plugin: 'groovy''を追加すると、その行に'プロジェクト上で'プラグイン 'プラグインを見つけることができませんでした:src:myproject''が表示されます。注意: 'build.gradle'の省略された部分にはgrgitに関連するものは何も含まれていませんので、必要な行がスニペットに含まれていなければ、ファイルにはどこにもないと考えることができます。 – user149408
@ user149408、あなたのエラーはなぜタスク '':src:myproject:clone''のためですか?私は2つのレベルのエラーを意味します。あなたは' ./gradlew tasks --all'を実行できますか? – chenrui