所以我正在尝试设置一个 gradle 多模块项目。
我的文件结构如下所示:
├── moduleA
│ ├── build.gradle
│ └── settings.gradle
└── moduleB
├── build.gradle
└── settings.gradle
build.gradle 的文件模块B :
plugins {
id("org.jetbrains.kotlin.jvm") version "1.3.60"
}
dependencies {
implementation project(':moduleA')
}
settings.gradle 对于模块B文件:
include "moduleA"
看起来一切正常,直到我尝试构建 模块B .
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.
我对 gradle 很陌生,我真的不明白那里发生了什么。
最佳答案
根据the docs on multi-project builds ,你应该有一个 settings.gradle
在根项目中,而不是在每个子项目中:
.
├── moduleA
│ └── build.gradle
├── moduleB
│ └── build.gradle
└── settings.gradle
并在 settings.gradle 中包含两个子项目:
include 'moduleA', 'moduleB'
关于gradle - 如何设置 gradle 多模块项目? (无法解析项目 :moduleA. ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59356555/