所以我正在尝试设置gradle多模块项目。
我的文件结构看起来像这样:
├── moduleA
│ ├── build.gradle
│ └── settings.gradle
└── moduleB
├── build.gradle
└── settings.gradle
moduleB 的 build.gradle 文件:
plugins {
id("org.jetbrains.kotlin.jvm") version "1.3.60"
}
dependencies {
implementation project(':moduleA')
}
moduleB文件的 settings.gradle :
include "moduleA"
在我尝试构建 moduleB 之前,一切都会顺利进行。
Could not determine the dependencies of task ':compileJava'.
> Could not resolve all task dependencies for configuration ':compileClasspath'.
> Could not resolve project :moduleA.
Required by:
project :
> Unable to find a matching configuration of project :moduleA:
- None of the consumable configurations have attributes.
我是新手,我不太了解那里发生了什么。
答案 0 :(得分:2)
根项目 settings.gradle
是您定义项目的地方。
rootProject.name = "my-project
include("moduleA")
include("moduleB")
答案 1 :(得分:2)
根据the docs on multi-project builds,您应该在根项目中而不是在每个子项目中都有一个settings.gradle
:
.
├── moduleA
│ └── build.gradle
├── moduleB
│ └── build.gradle
└── settings.gradle
并将两个子项目都包含在settings.gradle中:include 'moduleA', 'moduleB'