我试图使用多个子项目创建一个Gradle项目,util依赖于api项目,这两个项目位于同一个目录下:
├── mainFolder
│ ...
├── api
│ ├── src
│ │ └──...
│ └── build.gradle
├── util
│ ├── src
│ │ └──...
│ └── build.gradle
└── settings.gradleutil项目build.gradle
plugins {
id 'org.springframework.boot' version '2.7.5'
id 'io.spring.dependency-management' version '1.0.15.RELEASE'
id 'java'
}
group = 'my.package.util'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
ext {
springBootVersion = '2.7.5'
}
dependencies {
implementation platform("org.springframework.boot:spring-boot-dependencies:${springBootVersion}")
implementation project(':api')
implementation 'org.springframework.boot:spring-boot-starter-webflux'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'io.projectreactor:reactor-test'
}
tasks.named('test') {
useJUnitPlatform()
}util项目settings.gradle
rootProject.name = 'util'api项目build.gradle
plugins {
id 'org.springframework.boot' version '2.7.5'
id 'io.spring.dependency-management' version '1.0.15.RELEASE'
id 'java'
}
group = 'my.package.api'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
ext {
springBootVersion = '2.7.5'
}
dependencies {
implementation platform("org.springframework.boot:spring-boot-dependencies:${springBootVersion}")
implementation 'org.springframework.boot:spring-boot-starter-webflux'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'io.projectreactor:reactor-test'
}
tasks.named('test') {
useJUnitPlatform()
}api项目gradle.settings
rootProject.name = 'api'主要项目gradle.settings
include ':api'
include ':util'但是在运行gradle build之后,我总是收到以下错误消息:
A problem occurred evaluating root project 'util'.
Project with path ':api' could not be found in root project 'util'.任何提示我都会感激的,谢谢。
发布于 2022-11-08 16:37:08
我遗漏了一些配置,并从build.gradle文件中删除了一些不必要的库,这些库遵循了这个基本的教程。
https://stackoverflow.com/questions/74308054
复制相似问题