我有一个具有以下结构的多模块项目
当我尝试构建信号站点项目时,出现此异常
Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all task dependencies for configuration ':runtimeClasspath'.
settings.gradle.kts(交易)-顶级
rootProject.name = "trade"
include("trade-common")
include("signal-site")
build.gradle.kts(交易)-顶级
group = "com.oleinikdi"
version = "1.0"
subprojects {
version = "1.0"
}
allprojects {
repositories {
jcenter()
}
}
settings.gradle.kts(常见交易)
rootProject.name = "trade-common"
build.gradle.kts(常见交易)
subprojects {
version = "1.0"
}
plugins {
kotlin("jvm") version "1.3.70"
}
group = "com.oleinikdi"
version = "1.0"
repositories {
jcenter()
}
dependencies {
implementation(kotlin("stdlib-jdk8"))
}
tasks {
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
}
settings.gradle.kts(信号站点)
rootProject.name = "signal-site"
include("trade-common")
build.gradle.kts(信号站点)
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
subprojects {
version = "1.0"
}
plugins {
id("org.springframework.boot") version "2.2.5.RELEASE"
id("io.spring.dependency-management") version "1.0.9.RELEASE"
war
kotlin("jvm") version "1.3.70"
kotlin("plugin.spring") version "1.3.70"
kotlin("plugin.jpa") version "1.3.70"
}
group = "com.oleinik"
version = "1.0"
java.sourceCompatibility = JavaVersion.VERSION_1_8
repositories {
jcenter()
}
dependencies {
implementation(project(":trade-common"))
providedRuntime("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-data-rest")
implementation("org.springframework.boot:spring-boot-starter-jdbc")
implementation("org.springframework.boot:spring-boot-starter-security")
implementation("org.springframework.boot:spring-boot-starter-thymeleaf")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("org.liquibase:liquibase-core")
// runtimeOnly("org.postgresql:postgresql")
implementation("org.postgresql:postgresql")
providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
testImplementation("org.springframework.boot:spring-boot-starter-test") {
exclude(group = "org.junit.vintage", module = "junit-vintage-engine")
}
testImplementation("org.springframework.security:spring-security-test")
}
tasks.withType<Test> {
useJUnitPlatform()
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "1.8"
}
}
答案 0 :(得分:1)
在多项目构建中,项目的根目录必须只有一个 settings.gradle
文件。
因此,您的问题是由在层次结构中定义了多个settings.gradle
引起的,这意味着在signal-site
中运行某些内容时,Gradle被配置为将trade-common
查找为{{ 1}}。
只需删除signal-site
和trade-common
signal-site
文件,仅在根目录下保留一个即可。
请参阅the documentation,以更深入地了解Gradle settings.gradle
文件及其在多项目设置中的工作方式。