Update gradle scripts for latest gradle version

1. Use lazy property assignment
2. Remove usages of deprecated buildDir property
This commit is contained in:
Alexey Andreev 2023-09-21 09:52:29 +02:00
parent 2ae9c593d2
commit ba7dcd13b5
17 changed files with 65 additions and 65 deletions

View File

@ -61,7 +61,7 @@ gradlePlugin {
checkstyle { checkstyle {
toolVersion = libs.versions.checkstyle.get() toolVersion = libs.versions.checkstyle.get()
configDirectory.set(project.layout.projectDirectory.dir("../config/checkstyle")) configDirectory = project.layout.projectDirectory.dir("../config/checkstyle")
} }
java { java {

View File

@ -37,15 +37,15 @@ dependencies {
} }
tasks { tasks {
val generatedClassesDir = File(buildDir, "generated/classes/java/main") val generatedClassesDir = layout.buildDirectory.dir("generated/classes/java/main")
val generateTzCache by registering(JavaExec::class) { val generateTzCache by registering(JavaExec::class) {
val outputFile = File(generatedClassesDir, "org/teavm/classlib/impl/tz/cache") val outputFile = generatedClassesDir.map { it.dir( "org/teavm/classlib/impl/tz/cache") }
classpath(sourceSets.main.get().runtimeClasspath, sourceSets.main.get().compileClasspath) classpath(sourceSets.main.get().runtimeClasspath, sourceSets.main.get().compileClasspath)
outputs.file(outputFile) outputs.file(outputFile)
inputs.files(sourceSets.main.get().runtimeClasspath) inputs.files(sourceSets.main.get().runtimeClasspath)
dependsOn(compileJava) dependsOn(compileJava)
mainClass.set("org.teavm.classlib.impl.tz.TimeZoneCache") mainClass = "org.teavm.classlib.impl.tz.TimeZoneCache"
args(outputFile.absolutePath) args(outputFile.get().asFile.absolutePath)
} }
jar { jar {
dependsOn(generateTzCache) dependsOn(generateTzCache)

View File

@ -30,8 +30,8 @@ dependencies {
} }
teavm.js { teavm.js {
addedToWebApp.set(true) addedToWebApp = true
mainClass.set("org.teavm.samples.async.AsyncProgram") mainClass = "org.teavm.samples.async.AsyncProgram"
} }
tasks.war { tasks.war {

View File

@ -43,18 +43,18 @@ val executableFile = File(buildDir, "dist/teavm_benchmark")
teavm { teavm {
js { js {
addedToWebApp.set(true) addedToWebApp = true
mainClass.set("org.teavm.samples.benchmark.teavm.BenchmarkStarter") mainClass = "org.teavm.samples.benchmark.teavm.BenchmarkStarter"
debugInformation.set(true) debugInformation = true
} }
wasm { wasm {
addedToWebApp.set(true) addedToWebApp = true
mainClass.set("org.teavm.samples.benchmark.teavm.WasmBenchmarkStarter") mainClass = "org.teavm.samples.benchmark.teavm.WasmBenchmarkStarter"
} }
c { c {
mainClass.set("org.teavm.samples.benchmark.teavm.Gtk3BenchmarkStarter") mainClass = "org.teavm.samples.benchmark.teavm.Gtk3BenchmarkStarter"
relativePathInOutputDir.set("") relativePathInOutputDir = ""
outputDir.set(generatedCSources) outputDir = generatedCSources
} }
} }

View File

@ -26,6 +26,6 @@ dependencies {
} }
teavm.js { teavm.js {
addedToWebApp.set(true) addedToWebApp = true
mainClass.set("org.teavm.samples.hello.Client") mainClass = "org.teavm.samples.hello.Client"
} }

View File

@ -25,6 +25,6 @@ dependencies {
} }
teavm.js { teavm.js {
addedToWebApp.set(true) addedToWebApp = true
mainClass.set("org.teavm.samples.kotlin.HelloKt") mainClass = "org.teavm.samples.kotlin.HelloKt"
} }

View File

@ -30,17 +30,17 @@ dependencies {
teavm { teavm {
js { js {
addedToWebApp.set(true) addedToWebApp = true
} }
wasm { wasm {
addedToWebApp.set(true) addedToWebApp = true
} }
wasi { wasi {
outputDir.set(File(buildDir, "libs/wasi")) outputDir = layout.buildDirectory.dir("libs/wasi").get().asFile
relativePathInOutputDir.set("") relativePathInOutputDir = ""
} }
all { all {
mainClass.set("org.teavm.samples.pi.PiCalculator") mainClass = "org.teavm.samples.pi.PiCalculator"
} }
} }
@ -56,7 +56,7 @@ tasks.assemble {
val buildNativeLinux by tasks.register<Exec>("buildNativeLinux") { val buildNativeLinux by tasks.register<Exec>("buildNativeLinux") {
group = "build" group = "build"
dependsOn(tasks.generateC) dependsOn(tasks.generateC)
inputs.dir(File(buildDir, "generated/teavm/c")) inputs.dir(layout.buildDirectory.dir("generated/teavm/c"))
inputs.file(project.file("CMakeLists.txt")) inputs.file(project.file("CMakeLists.txt"))
outputs.file("build/dist/calc_pi") outputs.file("build/dist/calc_pi")
executable = "./build-native.sh" executable = "./build-native.sh"

View File

@ -26,6 +26,6 @@ dependencies {
} }
teavm.js { teavm.js {
addedToWebApp.set(true) addedToWebApp = true
mainClass.set("org.teavm.samples.scala.Client") mainClass = "org.teavm.samples.scala.Client"
} }

View File

@ -85,7 +85,7 @@ gradle.afterProject {
extensions.configure<CheckstyleExtension> { extensions.configure<CheckstyleExtension> {
toolVersion = extensions.getByType<VersionCatalogsExtension>().named("libs") toolVersion = extensions.getByType<VersionCatalogsExtension>().named("libs")
.findVersion("checkstyle").get().requiredVersion .findVersion("checkstyle").get().requiredVersion
configDirectory.set(File(settings.rootDir, "../config/checkstyle")) configDirectory = File(settings.rootDir, "../config/checkstyle")
} }
java.sourceCompatibility = JavaVersion.VERSION_11 java.sourceCompatibility = JavaVersion.VERSION_11
java.targetCompatibility = JavaVersion.VERSION_11 java.targetCompatibility = JavaVersion.VERSION_11

View File

@ -25,6 +25,6 @@ dependencies {
} }
teavm.js { teavm.js {
addedToWebApp.set(true) addedToWebApp = true
mainClass.set("org.teavm.samples.webapis.Main") mainClass = "org.teavm.samples.webapis.Main"
} }

View File

@ -95,29 +95,29 @@ gradle.afterProject {
} }
fun MavenPom.setupPom(project: Project) { fun MavenPom.setupPom(project: Project) {
name.set(project.description) name = project.description
description.set(project.description) description = project.description
licenses { licenses {
license { license {
name.set("The Apache Software License, Version 2.0") name = "The Apache Software License, Version 2.0"
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
distribution.set("repo") distribution = "repo"
comments.set("A business-friendly OSS license") comments = "A business-friendly OSS license"
} }
} }
developers { developers {
developer { developer {
id.set("konsoletyper") id = "konsoletyper"
name.set("Alexey Andreev") name = "Alexey Andreev"
email.set("konsoletyper@gmail.com") email = "konsoletyper@gmail.com"
timezone.set("Europe/Berlin") timezone = "Europe/Berlin"
} }
} }
scm { scm {
url.set("https://github.com/konsoletyper/teavm") url = "https://github.com/konsoletyper/teavm"
connection.set("scm:git:git@github.com:konsoletyper/teavm.git") connection = "scm:git:git@github.com:konsoletyper/teavm.git"
} }
url.set("https://teavm.org") url = "https://teavm.org"
} }
extensions.configure<DependencyRelocationExtension> { extensions.configure<DependencyRelocationExtension> {

View File

@ -39,7 +39,7 @@ dependencies {
} }
tasks.test { tasks.test {
systemProperty("teavm.junit.target", "${project.buildDir.absolutePath }/teavm-tests") systemProperty("teavm.junit.target", layout.buildDirectory.dir("teavm-tests").get().asFile.absolutePath)
systemProperty("teavm.junit.threads", "1") systemProperty("teavm.junit.threads", "1")
val browser = providers.gradleProperty("teavm.tests.browser").orElse("browser-chrome").get() val browser = providers.gradleProperty("teavm.tests.browser").orElse("browser-chrome").get()

View File

@ -33,7 +33,7 @@ val generateComparison by tasks.register<JavaExec>("generateComparison") {
inputs.files(tasks["relocateJar"].outputs.files) inputs.files(tasks["relocateJar"].outputs.files)
outputs.dir(outputDir) outputs.dir(outputDir)
classpath = configurations.runtimeClasspath.get() + tasks["relocateJar"].outputs.files classpath = configurations.runtimeClasspath.get() + tasks["relocateJar"].outputs.files
mainClass.set("org.teavm.tools.classlibcomparison.JCLComparisonBuilder") mainClass = "org.teavm.tools.classlibcomparison.JCLComparisonBuilder"
args("-output", outputDir.get().asFile.absolutePath) args("-output", outputDir.get().asFile.absolutePath)
} }

View File

@ -35,37 +35,37 @@ dependencies {
} }
val generateJs by tasks.register<JavaExec>("generateJs") { val generateJs by tasks.register<JavaExec>("generateJs") {
outputs.dir(File(buildDir, "teavm")) outputs.dir(layout.buildDirectory.dir("teavm"))
dependsOn(tasks.classes) dependsOn(tasks.classes)
classpath += configurations["teavmCompile"] classpath += configurations["teavmCompile"]
classpath += java.sourceSets.main.get().output.classesDirs classpath += java.sourceSets.main.get().output.classesDirs
mainClass.set("org.teavm.tooling.deobfuscate.js.Compiler") mainClass = "org.teavm.tooling.deobfuscate.js.Compiler"
args( args(
"org.teavm.tooling.deobfuscate.js.Deobfuscator", "org.teavm.tooling.deobfuscate.js.Deobfuscator",
"\$teavm_deobfuscator", "\$teavm_deobfuscator",
File(buildDir, "teavm").absolutePath, layout.buildDirectory.dir("teavm").get().asFile.absolutePath,
"deobfuscator.js" "deobfuscator.js"
) )
} }
val generateLibJs by tasks.register<JavaExec>("generateLibJs") { val generateLibJs by tasks.register<JavaExec>("generateLibJs") {
outputs.dir(File(buildDir, "teavm-lib")) outputs.dir(layout.buildDirectory.dir("teavm-lib"))
dependsOn(tasks.classes) dependsOn(tasks.classes)
classpath += configurations["teavmCompile"] classpath += configurations["teavmCompile"]
classpath += java.sourceSets.main.get().output.classesDirs classpath += java.sourceSets.main.get().output.classesDirs
mainClass.set("org.teavm.tooling.deobfuscate.js.Compiler") mainClass = "org.teavm.tooling.deobfuscate.js.Compiler"
args( args(
"org.teavm.tooling.deobfuscate.js.DeobfuscatorLib", "org.teavm.tooling.deobfuscate.js.DeobfuscatorLib",
"deobfuscator", "deobfuscator",
File(buildDir, "teavm-lib").absolutePath, layout.buildDirectory.dir("teavm-lib").get().asFile.absolutePath,
"deobfuscator-lib.js", "deobfuscator-lib.js",
) )
} }
val zipWithJs by tasks.register<Jar>("zipWithJs") { val zipWithJs by tasks.register<Jar>("zipWithJs") {
dependsOn(generateJs, generateLibJs) dependsOn(generateJs, generateLibJs)
archiveClassifier.set("js") archiveClassifier = "js"
from(File(buildDir, "teavm"), File(buildDir, "teavm-lib")) from(layout.buildDirectory.dir("teavm"), layout.buildDirectory.dir("teavm-lib"))
entryCompression = ZipEntryCompression.DEFLATED entryCompression = ZipEntryCompression.DEFLATED
} }

View File

@ -29,22 +29,22 @@ dependencies {
} }
gradlePlugin { gradlePlugin {
website.set("https://teavm.org") website = "https://teavm.org"
vcsUrl.set("https://github.com/konsoletyper/teavm") vcsUrl = "https://github.com/konsoletyper/teavm"
plugins { plugins {
create("TeaVMPlugin") { create("TeaVMPlugin") {
id = "org.teavm" id = "org.teavm"
implementationClass = "org.teavm.gradle.TeaVMPlugin" implementationClass = "org.teavm.gradle.TeaVMPlugin"
displayName = "TeaVM application plugin" displayName = "TeaVM application plugin"
description = "Installs TeaVM compilation tasks, configurations and source sets" description = "Installs TeaVM compilation tasks, configurations and source sets"
tags.set(listOf("teavm", "javascript", "webassembly", "compiler", "aot-compiler")) tags = listOf("teavm", "javascript", "webassembly", "compiler", "aot-compiler")
} }
create("TeaVMLibraryPlugin") { create("TeaVMLibraryPlugin") {
id = "org.teavm.library" id = "org.teavm.library"
implementationClass = "org.teavm.gradle.TeaVMLibraryPlugin" implementationClass = "org.teavm.gradle.TeaVMLibraryPlugin"
displayName = "TeaVM library plugin" displayName = "TeaVM library plugin"
description = "Installs TeaVM DSL for consuming TeaVM libraries and running tests in a browser" description = "Installs TeaVM DSL for consuming TeaVM libraries and running tests in a browser"
tags.set(listOf("teavm", "javascript", "webassembly", "compiler", "aot-compiler")) tags = listOf("teavm", "javascript", "webassembly", "compiler", "aot-compiler")
} }
} }
} }

View File

@ -29,6 +29,6 @@ dependencies {
} }
tasks.shadowJar { tasks.shadowJar {
archiveFileName.set("teavm.jar") archiveFileName = "teavm.jar"
mergeServiceFiles() mergeServiceFiles()
} }

View File

@ -20,15 +20,15 @@ plugins {
} }
intellij { intellij {
version.set(libs.versions.idea.asProvider().get()) version = libs.versions.idea.asProvider().get()
type.set("IC") type = "IC"
updateSinceUntilBuild.set(false) updateSinceUntilBuild = false
plugins.set(listOf( plugins = listOf(
"java", "java",
"org.intellij.scala:${libs.versions.idea.scala.get()}", "org.intellij.scala:${libs.versions.idea.scala.get()}",
"org.jetbrains.kotlin" "org.jetbrains.kotlin"
)) )
} }
dependencies { dependencies {
@ -37,13 +37,13 @@ dependencies {
tasks { tasks {
instrumentedJar { instrumentedJar {
archiveFileName.set("teavm-plugin.jar") archiveFileName = "teavm-plugin.jar"
} }
buildSearchableOptions { buildSearchableOptions {
enabled = false enabled = false
} }
publishPlugin { publishPlugin {
token.set(providers.gradleProperty("teavm.idea.publishToken")) token = providers.gradleProperty("teavm.idea.publishToken")
} }
} }