我正在尝试为所有子项目配置存储库。
我有主要的build.gradle
:
buildscript {
repositories {
mavenLocal()
mavenCentral()
google()
jcenter()
...
}
dependencies {
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
plugins {
id 'base'
}
allprojects {
apply plugin: 'base'
repositories {
mavenLocal()
mavenCentral()
google()
jcentre()
...
}
wrapper{
gradleVersion = '6.5.1'
distributionType = Wrapper.DistributionType.ALL
}
dependencies {
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
在子项目中build.gradle
我只有:
...
dependencies {
implementation ....
}
我正进入(状态:
Execution failed for task ':compileJava'.
> Could not resolve all files for configuration ':compileClasspath'.
> Cannot resolve external dependency .... because no repositories are defined.
Required by:
project :
我想定义repositories
一旦在主文件中,因为这些在子项目中不会改变。
In the settings.gradle
我的主要项目:
rootProject.name = 'main-project-name'
include 'sub-project-name'
并且在settings.gradle
我有的子项目:
rootProject.name = 'sub-project-name'
Gradle 中的多项目构建可能有多个build.gradle
文件,但只有一个settings.gradle
文件(通常位于项目根目录中)。你的第二个settings.gradle
文件定义了仅包含单个项目的第二个设置。您可以通过运行来检查这一点gradle projects
。删除第二个就好了settings.gradle
文件来解决您的问题。
通常,您可以通过命名相应的目录来简单地定义子项目的名称,然后调用include
。的名称rootProject
可以定义在里面settings.gradle
,因为目录的名称通常不存储在 Git 等版本控制系统中。开发人员可能会将存储库检出到不同的目录,从而导致 Gradle 对根项目使用不同的名称。如果您希望子项目具有与其包含目录不同的名称,请使用include
使用所需的名称,然后通过更改项目目录project(':foo').projectDir = file('path/to/foo')
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)