Gradle 使用ext

Gradle 版本

Gradle Version: 8.2.1

ext 使用

build.gradle.kts

ext {
    set("log4j2-version", "2.20.0")
    set("slf4j-version", "2.0.7")
}

tasks.register("testaaa") {
   println("${project.ext["log4j2-version"]}");
}

dependencies {
	implementation ("org.apache.logging.log4j:log4j-core:${project.ext["log4j2-version"]}")
}

build.gradle

ext {
	log4j2Version = "2.20.0"
}

task "aaa" {
	println(log4j2Version)
}

dependencies {
	implementation "org.jetbrains.kotlin:kotlin-gradle-plugin:$log4j2Version"
}

你可能感兴趣的:(Gradle,gradle)