如何设置 gradle 多模块项目? (无法解析项目:moduleS。)
How to setup a gradle multi module project? (Could not resolve project :moduleA.)
所以我正在尝试设置一个 gradle 多模块项目。
我的文件结构如下所示:
├── moduleA
│ ├── build.gradle
│ └── settings.gradle
└── moduleB
├── build.gradle
└── settings.gradle
build.gradle文件moduleB:
plugins {
id("org.jetbrains.kotlin.jvm") version "1.3.60"
}
dependencies {
implementation project(':moduleA')
}
模块B文件的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.
我是 gradle 的新手,我真的不明白那里发生了什么。
根项目 settings.gradle
是您定义项目的地方。
rootProject.name = "my-project
include("moduleA")
include("moduleB")
根据 the docs on multi-project builds,你应该在根项目中有一个 settings.gradle
,而不是在每个子项目中:
.
├── moduleA
│ └── build.gradle
├── moduleB
│ └── build.gradle
└── settings.gradle
并在 settings.gradle 中包含两个子项目:include 'moduleA', 'moduleB'
所以我正在尝试设置一个 gradle 多模块项目。
我的文件结构如下所示:
├── moduleA
│ ├── build.gradle
│ └── settings.gradle
└── moduleB
├── build.gradle
└── settings.gradle
build.gradle文件moduleB:
plugins {
id("org.jetbrains.kotlin.jvm") version "1.3.60"
}
dependencies {
implementation project(':moduleA')
}
模块B文件的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.
我是 gradle 的新手,我真的不明白那里发生了什么。
根项目 settings.gradle
是您定义项目的地方。
rootProject.name = "my-project
include("moduleA")
include("moduleB")
根据 the docs on multi-project builds,你应该在根项目中有一个 settings.gradle
,而不是在每个子项目中:
.
├── moduleA
│ └── build.gradle
├── moduleB
│ └── build.gradle
└── settings.gradle
并在 settings.gradle 中包含两个子项目:include 'moduleA', 'moduleB'