Migrate Gradle delegated properties (#1782)

There were some more that we missed last time around
This commit is contained in:
Daniel Chao
2026-07-16 15:41:28 -07:00
committed by Dan Chao
parent d9bc5a5e5d
commit 4ba3d8e7d6
2 changed files with 45 additions and 44 deletions
+7 -7
View File
@@ -22,11 +22,11 @@ plugins {
signing
}
val pklCodegenJava: Configuration by configurations.creating
val firstPartySourcesJars by configurations.existing
val pklCodegenJava: Configuration = configurations.create("pklCodegenJava")
val firstPartySourcesJars = configurations.named("firstPartySourcesJars")
val generateTestConfigClasses by
tasks.registering(JavaExec::class) {
val generateTestConfigClasses =
tasks.register<JavaExec>("generateTestConfigClasses") {
val outputDir = layout.buildDirectory.dir("testConfigClasses")
outputs.dir(outputDir)
inputs.dir("src/test/resources/codegenPkl")
@@ -45,13 +45,13 @@ tasks.processTestResources { dependsOn(generateTestConfigClasses) }
tasks.compileTestKotlin { dependsOn(generateTestConfigClasses) }
val bundleTests by tasks.registering(Jar::class) { from(sourceSets.test.get().output) }
val bundleTests = tasks.register<Jar>("bundleTests") { from(sourceSets.test.get().output) }
// Runs unit tests using jar'd class files as a source.
// This is to test loading the ClassRegistry from within a jar, as opposed to directly from the file
// system.
val testFromJar by
tasks.registering(Test::class) {
val testFromJar =
tasks.register<Test>("testFromJar") {
dependsOn(bundleTests)
testClassesDirs = files(tasks.test.get().testClassesDirs)
+38 -37
View File
@@ -138,36 +138,37 @@ tasks.withType<JavaCompile>().configureEach {
tasks.compileKotlin { enabled = false }
val externalReaderFixture by tasks.registering {
group = "build"
dependsOn(tasks.named("compileExternalReaderFixtureJava"))
inputs.files(externalReaderFixtureSourceSet.map { it.output })
val fileName = if (buildInfo.os.isWindows) "externalreader.bat" else "externalreader"
val outputFile = layout.buildDirectory.file("fixtures/$fileName")
outputs.file(outputFile)
doLast {
val classpath = externalReaderFixtureSourceSet.get().runtimeClasspath.asPath
val scriptContent =
if (buildInfo.os.isWindows) {
"""
val externalReaderFixture =
tasks.register("externalReaderFixture") {
group = "build"
dependsOn(tasks.named("compileExternalReaderFixtureJava"))
inputs.files(externalReaderFixtureSourceSet.map { it.output })
val fileName = if (buildInfo.os.isWindows) "externalreader.bat" else "externalreader"
val outputFile = layout.buildDirectory.file("fixtures/$fileName")
outputs.file(outputFile)
doLast {
val classpath = externalReaderFixtureSourceSet.get().runtimeClasspath.asPath
val scriptContent =
if (buildInfo.os.isWindows) {
"""
@echo off
java -cp $classpath org.pkl.core.externalreaderfixture.Main
"""
.trimIndent()
} else {
"""
.trimIndent()
} else {
"""
#!/usr/bin/env bash
java -cp $classpath org.pkl.core.externalreaderfixture.Main
"""
.trimIndent()
}
.trimIndent()
}
outputFile.get().asFile.writeText(scriptContent)
outputFile.get().asFile.setExecutable(true)
println("Created external reader ${outputFile.get().asFile.absolutePath}")
outputFile.get().asFile.writeText(scriptContent)
outputFile.get().asFile.setExecutable(true)
println("Created external reader ${outputFile.get().asFile.absolutePath}")
}
}
}
tasks.test {
configureTest()
@@ -195,8 +196,8 @@ tasks.test {
)
}
val generateBaseModuleMembers by
tasks.registering(JavaExec::class) {
val generateBaseModuleMembers =
tasks.register<JavaExec>("generateBaseModuleMembers") {
group = "build"
val outputDir = layout.buildDirectory.dir("generated/sources/baseModuleMembers")
@@ -227,8 +228,8 @@ tasks.compileJava { dependsOn(generateBaseModuleMembers) }
tasks.sourcesJar { dependsOn(generateBaseModuleMembers) }
val testJavaExecutable by
tasks.registering(Test::class) {
val testJavaExecutable =
tasks.register<Test>("testJavaExecutable") {
configureExecutableTest("LanguageSnippetTestsEngine")
classpath =
// compiled test classes
@@ -247,38 +248,38 @@ val testJavaExecutable by
tasks.check { dependsOn(testJavaExecutable) }
val testMacExecutableAmd64 by
tasks.registering(Test::class) {
val testMacExecutableAmd64 =
tasks.register<Test>("testMacExecutableAmd64") {
dependsOn(":pkl-cli:macExecutableAmd64")
configureExecutableTest("MacAmd64LanguageSnippetTestsEngine")
}
val testMacExecutableAarch64 by
tasks.registering(Test::class) {
val testMacExecutableAarch64 =
tasks.register<Test>("testMacExecutableAarch64") {
dependsOn(":pkl-cli:macExecutableAarch64")
configureExecutableTest("MacAarch64LanguageSnippetTestsEngine")
}
val testLinuxExecutableAmd64 by
tasks.registering(Test::class) {
val testLinuxExecutableAmd64 =
tasks.register<Test>("testLinuxExecutableAmd64") {
dependsOn(":pkl-cli:linuxExecutableAmd64")
configureExecutableTest("LinuxAmd64LanguageSnippetTestsEngine")
}
val testLinuxExecutableAarch64 by
tasks.registering(Test::class) {
val testLinuxExecutableAarch64 =
tasks.register<Test>("testLinuxExecutableAarch64") {
dependsOn(":pkl-cli:linuxExecutableAarch64")
configureExecutableTest("LinuxAarch64LanguageSnippetTestsEngine")
}
val testAlpineExecutableAmd64 by
tasks.registering(Test::class) {
val testAlpineExecutableAmd64 =
tasks.register<Test>("testAlpineExecutableAmd64") {
dependsOn(":pkl-cli:alpineExecutableAmd64")
configureExecutableTest("AlpineLanguageSnippetTestsEngine")
}
val testWindowsExecutableAmd64 by
tasks.registering(Test::class) {
val testWindowsExecutableAmd64 =
tasks.register<Test>("testWindowsExecutableAmd64") {
dependsOn(":pkl-cli:windowsExecutableAmd64")
configureExecutableTest("WindowsLanguageSnippetTestsEngine")
}