最近在接触一个gradle构建方式的老项目时,编译项目时出现如标题所示错误
然后在网上找了一堆答案也没有找到正确的解决办法,后面仔细研究了一下gradle.build配置文件,
buildscript {
......
}
apply plugin: 'java'
apply plugin: 'application'
jar {
baseName = 'xxx'
version = '0.1.0'
}
dependencies {
compile "xxx:xxx:xxx"
.......
}
task wrapper(type: Wrapper) {
gradleVersion = '1.11'
}
发现模块中少了repositories配置项,然后在buildscript{}块中和顶级配置中分别配置了repositories配置项,问题解决.
buildscript {
repositories {
mavenCentral()
}
apply plugin: 'java'
apply plugin: 'application'
repositories {
mavenCentral()
}
jar {
baseName = 'xxx'
version = '0.1.0'
}
dependencies {
compile "xxx:xxx:xxx"
}
task wrapper(type: Wrapper) {
gradleVersion = '1.11'
}

本文详细解析了在使用Gradle构建老项目时遇到的错误及其解决过程。通过深入研究build.gradle配置文件,发现缺少repositories配置项是导致问题的关键。文章分享了如何在buildscript{}

1万+

被折叠的 条评论
为什么被折叠?



