gpt4 book ai didi

gradle - gradle错误:使用kotlin DSL时,在应用Aspectj插件之前 “You must set the property ' AspectjVersion'

转载 作者:行者123 更新时间:2023-12-03 03:07:28 26 4
gpt4 key购买 nike

我想在我的使用Kotlin DSL的gradle项目中配​​置AspectJ插件。

以下是我的build.gradle.kts文件。

    val aspectjVersion = "1.9.3"

plugins {
java
id("aspectj.gradle") version "0.1.6"
}

group = "java-agents-demo"
version = "1.0-SNAPSHOT"

repositories {
mavenCentral()
mavenLocal()
jcenter()
}

dependencies {
implementation("org.aspectj","aspectjrt", aspectjVersion)
implementation("org.aspectj","aspectjweaver", aspectjVersion)
testCompile("junit", "junit", "4.12")
}

configure<JavaPluginConvention> {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

当我运行 compileJava项目时,出现错误“您必须在应用Aspectj插件之前设置属性'aspectjVersion'”。

我在构建文件中设置了 aspectjVersion,但我不知道其中有什么错误。

谁能帮助我以正确的方式为我的项目设置AspectJ插件?

最佳答案

因此val aspectjVersion = "1.9.3"定义了一个局部变量,但是插件正在寻找项目属性,请注意,这也意味着不能立即应用该插件,因为在其余build.gradle.kts之前先评估插件块(请参阅limitations of plugin DSL),请尝试一下代替:

val aspectjVersion by extra("1.9.3")

plugins {
java
id("aspectj.gradle") version "0.1.6" apply false
}

apply(plugin = "aspectj.gradle")

有关详细信息,请参见 extra properties上的Gradle文档。

关于gradle - gradle错误:使用kotlin DSL时,在应用Aspectj插件之前 “You must set the property ' AspectjVersion',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55753896/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com