【发布时间】:2021-10-17 20:06:00
【问题描述】:
我创建了一个名为my-root-project的gradle项目,在其下还有另外两个gradle项目:shared和my-service。
在我的 IntelliJ IDE 中,我添加了 shared 和 my-service 作为 my-root-project 的模块。项目结构整体如下:
-my-root-project
-shared
-build.gradle
-settings.gradle
-my-service
-build.gradle
-settings.gradle
-build.gradle
-settings.gradle
...
在my-root-project 的settings.gradle 中,我有:
rootProject.name = 'my-root-project'
include ':shared'
include ':my-service'
在my-service 的build.gradle 中,我想添加shared 作为其项目依赖项:
...
dependencies {
implementation project(':shared')
}
但我得到错误:
A problem occurred evaluating root project 'my-service'.
> Project with path ':shared' could not be found in root project 'my-service'.
然后,我尝试将shared 也包含在my-service 的settings.gradle 中。 (以上,我已经将它包含在my-root-project的settings.gradle中)。
然后,再次构建,但出现新错误:
Could not resolve project :shared.
Required by:
project :
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
我哪里错了?我想让shared 项目成为my-service 中的依赖项。
【问题讨论】:
标签: gradle build.gradle gradlew