我在我的Kotlin-Gradle多模块项目中使用io.freefair.aspectj.post-compile-weaving
插件在我的SprringBoot应用程序中启用方面.
当我try 在一个简单的项目中使用这个插件时,它工作得非常好,当我将项目拆分成一个多模块的项目时,它开始不再识别方面
这是我在GitHub上创建的MCVE.
因此,我基本上设置了根项目Gradle文件:
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("org.springframework.boot") version "3.1.5"
id("io.spring.dependency-management") version "1.1.3"
id("io.freefair.aspectj.post-compile-weaving") version "6.6.3"
kotlin("jvm") version "1.8.22"
kotlin("plugin.spring") version "1.8.22"
}
group = "com.voiddev"
allprojects {
apply(plugin = "org.jetbrains.kotlin.jvm")
apply(plugin = "kotlin-spring")
apply(plugin = "io.spring.dependency-management")
apply(plugin = "org.springframework.boot")
apply(plugin = "io.freefair.aspectj.post-compile-weaving")
version = "0.0.1-SNAPSHOT"
java {
sourceCompatibility = JavaVersion.VERSION_17
}
repositories {
mavenCentral()
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect")
testImplementation("org.springframework.boot:spring-boot-starter-test")
implementation("org.aspectj:aspectjrt:1.9.19")
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs += "-Xjsr305=strict"
jvmTarget = "17"
}
}
tasks.withType<Test> {
useJUnitPlatform()
}
}
然后,我所要做的就是try 使用‘公共’模块中定义的方面,在‘服务器’模块中.
我确实正确地导入了服务器模块中的公共模块,因为我能够访问common
模块中定义的类.
这是我的服务器Gradle文件:
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("org.springframework.boot") version "3.1.5"
id("io.spring.dependency-management") version "1.1.3"
id("io.freefair.aspectj.post-compile-weaving") version "6.6.3"
kotlin("jvm") version "1.8.22"
kotlin("plugin.spring") version "1.8.22"
}
group = "com.voiddev"
dependencies {
implementation(project(":common"))
}
tasks {
bootJar {
archiveBaseName.set(rootProject.name)
}
}
然而,这些方面被简单地忽略了