Kotlin Gradle项目中Freefair AspectJ插件配置失效求助
Kotlin Gradle项目配置Freefair AspectJ插件切面不生效问题
我在Kotlin Gradle项目中配置Freefair AspectJ插件时遇到问题:应用启动无异常,但切面未生效。我将切面文件MetricAspect.kt放置在src/main/aspectj源码目录下,当前build.gradle.kts配置如下:
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { //other plugins id("io.freefair.aspectj") version "6.6.3" val kotlinVersion = "1.7.21" kotlin("jvm") version kotlinVersion kotlin("plugin.spring") version kotlinVersion //other plugins } allprojects { apply(plugin = "org.jetbrains.kotlin.jvm") apply(plugin = "io.gitlab.arturbosch.detekt") apply(plugin = "com.diffplug.spotless") apply(plugin = "io.freefair.aspectj") apply(plugin = "kotlin-spring") version = "1.0.0-SNAPSHOT" java { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 } repositories { maven { url = uri("https://private.repo/public-maven-virtual/") credentials { username = user password = password } } } dependencies { kotlinCompilerPluginClasspath("gradle.plugin.aspectj:gradle-aspectj:0.1.6") //other deps implementation("org.aspectj:aspectjrt:1.9.7") annotationProcessor("org.aspectj:aspectjtools:1.9.7") //other deps } tasks.withType<KotlinCompile> { kotlinOptions { freeCompilerArgs = listOf("-Xjsr305=strict") jvmTarget = "17" } } tasks.withType<Test> { useJUnitPlatform() } spotless { //.... } detekt { buildUponDefaultConfig = true // preconfigure defaults allRules = false // activate all available (even unstable) rules. parallel = true config = files("$rootDir/detekt.yml") } } tasks { bootJar { enabled = false } }
相关文档十分匮乏,且配置方式众说纷纭,请问是否有官方标准配置方式?
内容的提问来源于stack exchange,提问作者L_Cleo
相关产品推荐
相关产品推荐

