gpt4 book ai didi

java - grgit NoClassDefFoundError

转载 作者:行者123 更新时间:2023-12-03 06:27:42 25 4
gpt4 key购买 nike

尝试执行grgit任务时,Gradle会引发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添加为构建依赖项(错误消息似乎表明了这一点)?我将如何以及在哪里添加它?

编辑:gradle版本是1.10,如果有关系。

最佳答案

正如@ user149408指出Gradle版本(v1.10与v2.10)不匹配时,我进一步挖掘了一点:

gradle-git-plugin commit for v0.7.0指定使用的Gradle版本(v1.11),因此使用v1.10的构建可以正常工作。

因为Gradle插件始终使用Gradle的compile localGroovy()compile gradleApi()构建,所以如果使用Gradle 2.x进行构建,则将引发Groovy不匹配错误。

  • What went wrong: Execution failed for task ':src:myproject:clone'. java.lang.NoClassDefFoundError: org/codehaus/groovy/runtime/typehandling/ShortTypeHandling


实际上,Gradle v2.10和gradle-git v1.2.0的组合可以正常工作。

一些示例 build.gradle与问题中的结构类似。
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.ajoberstar:gradle-git:1.2.0'
}
}

import org.ajoberstar.grgit.*

task clone << {
File dir = new File('contrib/gs-spring-boot')
if(!dir.exists()) {
def grgit = Grgit.clone(dir: dir, uri: 'https://github.com/chenrui333/gs-spring-boot.git')
}
// TODO else (pull)
}
./gradlew clone将给您:
$ ls contrib/gs-spring-boot/
CONTRIBUTING.adoc LICENSE.code.txt LICENSE.writing.txt README.adoc complete initial test

希望能帮助到你!

关于java - grgit NoClassDefFoundError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45154446/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com