Migrate Gradle deprecations (#1745)

This commit is contained in:
Daniel Chao
2026-07-08 12:05:19 -07:00
committed by GitHub
parent 25d86db416
commit 7a7f3abc50
22 changed files with 356 additions and 323 deletions
+2 -2
View File
@@ -19,8 +19,8 @@ plugins {
id("me.champeau.jmh") id("me.champeau.jmh")
} }
val truffle: Configuration by configurations.creating val truffle: Configuration = configurations.create("truffle")
val graal: Configuration by configurations.creating val graal: Configuration = configurations.create("graal")
dependencies { dependencies {
jmh(projects.pklCore) jmh(projects.pklCore)
+5 -3
View File
@@ -63,11 +63,13 @@ fun Project.configurePklPomMetadata() {
/** Configures POM validation task to check for unresolved versions and snapshots in releases. */ /** Configures POM validation task to check for unresolved versions and snapshots in releases. */
fun Project.configurePomValidation() { fun Project.configurePomValidation() {
val validatePom by tasks.registering { val validatePom =
tasks.register("validatePom") {
if (tasks.findByName("generatePomFileForLibraryPublication") == null) { if (tasks.findByName("generatePomFileForLibraryPublication") == null) {
return@registering return@register
} }
val generatePomFileForLibraryPublication by tasks.existing(GenerateMavenPom::class) val generatePomFileForLibraryPublication =
tasks.named<GenerateMavenPom>("generatePomFileForLibraryPublication")
val outputFile = val outputFile =
layout.buildDirectory.file("validatePom") // dummy output to satisfy up-to-date check layout.buildDirectory.file("validatePom") // dummy output to satisfy up-to-date check
@@ -79,7 +79,7 @@ plugins.withType(MavenPublishPlugin::class).configureEach {
} }
} }
val allDependencies by tasks.registering(DependencyReportTask::class) val allDependencies = tasks.register<DependencyReportTask>("allDependencies")
tasks.withType(Test::class).configureEach { tasks.withType(Test::class).configureEach {
System.getProperty("testReportsDir")?.let { reportsDir -> System.getProperty("testReportsDir")?.let { reportsDir ->
@@ -132,8 +132,8 @@ tasks.shadowJar {
shadow { addShadowVariantIntoJavaComponent = false } shadow { addShadowVariantIntoJavaComponent = false }
val testFatJar by val testFatJar =
tasks.registering(Test::class) { tasks.register<Test>("testFatJar") {
testClassesDirs = files(tasks.test.get().testClassesDirs) testClassesDirs = files(tasks.test.get().testClassesDirs)
classpath = classpath =
// compiled test classes // compiled test classes
@@ -148,7 +148,8 @@ val testFatJar by
tasks.check { dependsOn(testFatJar) } tasks.check { dependsOn(testFatJar) }
val validateFatJar by tasks.registering { val validateFatJar =
tasks.register("validateFatJar") {
val outputFile = layout.buildDirectory.file("validateFatJar/result.txt") val outputFile = layout.buildDirectory.file("validateFatJar/result.txt")
inputs.files(tasks.shadowJar) inputs.files(tasks.shadowJar)
inputs.property("nonRelocations", nonRelocations) inputs.property("nonRelocations", nonRelocations)
@@ -181,14 +182,14 @@ val validateFatJar by tasks.registering {
tasks.check { dependsOn(validateFatJar) } tasks.check { dependsOn(validateFatJar) }
val resolveSourcesJars by val resolveSourcesJars =
tasks.registering(ResolveSourcesJars::class) { tasks.register<ResolveSourcesJars>("resolveSourcesJars") {
configuration.set(configurations.runtimeClasspath) configuration.set(configurations.runtimeClasspath)
outputDir.set(layout.buildDirectory.dir("resolveSourcesJars")) outputDir.set(layout.buildDirectory.dir("resolveSourcesJars"))
} }
val fatSourcesJar by val fatSourcesJar =
tasks.registering(MergeSourcesJars::class) { tasks.register<MergeSourcesJars>("fatSourcesJar") {
plugins.withId("pklJavaLibrary") { inputJars.from(tasks.named("sourcesJar")) } plugins.withId("pklJavaLibrary") { inputJars.from(tasks.named("sourcesJar")) }
inputJars.from(firstPartySourcesJarsConfiguration) inputJars.from(firstPartySourcesJarsConfiguration)
inputJars.from(resolveSourcesJars.map { fileTree(it.outputDir) }) inputJars.from(resolveSourcesJars.map { fileTree(it.outputDir) })
@@ -213,7 +214,7 @@ publishing {
artifact(fatSourcesJar.flatMap { it.outputJar.asFile }) { classifier = "sources" } artifact(fatSourcesJar.flatMap { it.outputJar.asFile }) { classifier = "sources" }
plugins.withId("pklJavaLibrary") { plugins.withId("pklJavaLibrary") {
val javadocJar by tasks.existing(Jar::class) val javadocJar = tasks.named<Jar>("javadocJar")
// Javadoc Jar is not fat (didn't invest effort) // Javadoc Jar is not fat (didn't invest effort)
artifact(javadocJar.flatMap { it.archiveFile }) { classifier = "javadoc" } artifact(javadocJar.flatMap { it.archiveFile }) { classifier = "javadoc" }
} }
@@ -21,11 +21,15 @@ plugins { id("de.undercouch.download") }
val buildInfo = project.extensions.getByType<BuildInfo>() val buildInfo = project.extensions.getByType<BuildInfo>()
// tries to minimize chance of corruption by download-to-temp-file-and-move // tries to minimize chance of corruption by download-to-temp-file-and-move
val downloadGraalVmAarch64 by val downloadGraalVmAarch64 =
tasks.registering(Download::class) { configureDownloadGraalVm(buildInfo.graalVmAarch64) } tasks.register<Download>("downloadGraalVmAarch64") {
configureDownloadGraalVm(buildInfo.graalVmAarch64)
}
val downloadGraalVmAmd64 by val downloadGraalVmAmd64 =
tasks.registering(Download::class) { configureDownloadGraalVm(buildInfo.graalVmAmd64) } tasks.register<Download>("downloadGraalVmAmd64") {
configureDownloadGraalVm(buildInfo.graalVmAmd64)
}
fun Download.configureDownloadGraalVm(graalvm: BuildInfo.GraalVm) { fun Download.configureDownloadGraalVm(graalvm: BuildInfo.GraalVm) {
onlyIf { !graalvm.installDir.exists() } onlyIf { !graalvm.installDir.exists() }
@@ -37,14 +41,14 @@ fun Download.configureDownloadGraalVm(graalvm: BuildInfo.GraalVm) {
tempAndMove(true) tempAndMove(true)
} }
val verifyGraalVmAarch64 by val verifyGraalVmAarch64 =
tasks.registering(Verify::class) { tasks.register<Verify>("verifyGraalVmAarch64") {
configureVerifyGraalVm(buildInfo.graalVmAarch64) configureVerifyGraalVm(buildInfo.graalVmAarch64)
dependsOn(downloadGraalVmAarch64) dependsOn(downloadGraalVmAarch64)
} }
val verifyGraalVmAmd64 by val verifyGraalVmAmd64 =
tasks.registering(Verify::class) { tasks.register<Verify>("verifyGraalVmAmd64") {
configureVerifyGraalVm(buildInfo.graalVmAmd64) configureVerifyGraalVm(buildInfo.graalVmAmd64)
dependsOn(downloadGraalVmAmd64) dependsOn(downloadGraalVmAmd64)
} }
@@ -60,15 +64,15 @@ fun Verify.configureVerifyGraalVm(graalvm: BuildInfo.GraalVm) {
} }
@Suppress("unused") @Suppress("unused")
val installGraalVmAarch64 by val installGraalVmAarch64 =
tasks.registering(InstallGraalVm::class) { tasks.register<InstallGraalVm>("installGraalVmAarch64") {
dependsOn(verifyGraalVmAarch64) dependsOn(verifyGraalVmAarch64)
graalVm = buildInfo.graalVmAarch64 graalVm = buildInfo.graalVmAarch64
} }
@Suppress("unused") @Suppress("unused")
val installGraalVmAmd64 by val installGraalVmAmd64 =
tasks.registering(InstallGraalVm::class) { tasks.register<InstallGraalVm>("installGraalVmAmd64") {
dependsOn(verifyGraalVmAmd64) dependsOn(verifyGraalVmAmd64)
graalVm = buildInfo.graalVmAmd64 graalVm = buildInfo.graalVmAmd64
} }
@@ -47,8 +47,8 @@ dependencies {
} }
} }
val validateHtml by val validateHtml =
tasks.registering(JavaExec::class) { tasks.register<JavaExec>("validateHtml") {
val resultFile = layout.buildDirectory.file("validateHtml/result.txt") val resultFile = layout.buildDirectory.file("validateHtml/result.txt")
inputs.files(htmlValidator.sources) inputs.files(htmlValidator.sources)
outputs.file(resultFile) outputs.file(resultFile)
@@ -26,8 +26,8 @@ plugins {
val executableSpec = project.extensions.create("executable", ExecutableSpec::class.java) val executableSpec = project.extensions.create("executable", ExecutableSpec::class.java)
val buildInfo = project.extensions.getByType<BuildInfo>() val buildInfo = project.extensions.getByType<BuildInfo>()
val javaExecutable by val javaExecutable =
tasks.registering(ExecutableJar::class) { tasks.register<ExecutableJar>("javaExecutable") {
group = "build" group = "build"
dependsOn(tasks.jar) dependsOn(tasks.jar)
inJar = tasks.shadowJar.flatMap { it.archiveFile } inJar = tasks.shadowJar.flatMap { it.archiveFile }
@@ -77,7 +77,8 @@ fun Task.setupTestStartJavaExecutable(launcher: Provider<JavaLauncher>? = null)
} }
} }
val testStartJavaExecutable by tasks.registering { setupTestStartJavaExecutable() } val testStartJavaExecutable =
tasks.register("testStartJavaExecutable") { setupTestStartJavaExecutable() }
// Setup `testStartJavaExecutable` tasks for multi-JDK testing. // Setup `testStartJavaExecutable` tasks for multi-JDK testing.
val testStartJavaExecutableOnOtherJdks = val testStartJavaExecutableOnOtherJdks =
@@ -30,14 +30,18 @@ plugins {
val executableSpec = project.extensions.getByType<ExecutableSpec>() val executableSpec = project.extensions.getByType<ExecutableSpec>()
val buildInfo = project.extensions.getByType<BuildInfo>() val buildInfo = project.extensions.getByType<BuildInfo>()
val stagedMacAmd64Executable: Configuration by configurations.creating val stagedMacAmd64Executable: Configuration = configurations.create("stagedMacAmd64Executable")
val stagedMacAarch64Executable: Configuration by configurations.creating val stagedMacAarch64Executable: Configuration = configurations.create("stagedMacAarch64Executable")
val stagedLinuxAmd64Executable: Configuration by configurations.creating val stagedLinuxAmd64Executable: Configuration = configurations.create("stagedLinuxAmd64Executable")
val stagedLinuxAarch64Executable: Configuration by configurations.creating val stagedLinuxAarch64Executable: Configuration =
val stagedAlpineLinuxAmd64Executable: Configuration by configurations.creating configurations.create("stagedLinuxAarch64Executable")
val stagedWindowsAmd64Executable: Configuration by configurations.creating val stagedAlpineLinuxAmd64Executable: Configuration =
configurations.create("stagedAlpineLinuxAmd64Executable")
val stagedWindowsAmd64Executable: Configuration =
configurations.create("stagedWindowsAmd64Executable")
val nativeImageClasspath by configurations.creating { val nativeImageClasspath =
configurations.create("nativeImageClasspath") {
extendsFrom(configurations.runtimeClasspath.get()) extendsFrom(configurations.runtimeClasspath.get())
// Ensure native-image version uses GraalVM C SDKs instead of Java FFI or JNA // Ensure native-image version uses GraalVM C SDKs instead of Java FFI or JNA
// (comes from artifact `mordant-jvm-graal-ffi`). // (comes from artifact `mordant-jvm-graal-ffi`).
@@ -85,32 +89,32 @@ private fun NativeImageBuild.setClasspath() {
classpath.from(nativeImageClasspath) classpath.from(nativeImageClasspath)
} }
val macExecutableAmd64 by val macExecutableAmd64 =
tasks.registering(NativeImageBuild::class) { tasks.register<NativeImageBuild>("macExecutableAmd64") {
imageName = executableSpec.name.map { "$it-macos-amd64" } imageName = executableSpec.name.map { "$it-macos-amd64" }
mainClass = executableSpec.mainClass mainClass = executableSpec.mainClass
amd64() amd64()
setClasspath() setClasspath()
} }
val macExecutableAarch64 by val macExecutableAarch64 =
tasks.registering(NativeImageBuild::class) { tasks.register<NativeImageBuild>("macExecutableAarch64") {
imageName = executableSpec.name.map { "$it-macos-aarch64" } imageName = executableSpec.name.map { "$it-macos-aarch64" }
mainClass = executableSpec.mainClass mainClass = executableSpec.mainClass
aarch64() aarch64()
setClasspath() setClasspath()
} }
val linuxExecutableAmd64 by val linuxExecutableAmd64 =
tasks.registering(NativeImageBuild::class) { tasks.register<NativeImageBuild>("linuxExecutableAmd64") {
imageName = executableSpec.name.map { "$it-linux-amd64" } imageName = executableSpec.name.map { "$it-linux-amd64" }
mainClass = executableSpec.mainClass mainClass = executableSpec.mainClass
amd64() amd64()
setClasspath() setClasspath()
} }
val linuxExecutableAarch64 by val linuxExecutableAarch64 =
tasks.registering(NativeImageBuild::class) { tasks.register<NativeImageBuild>("linuxExecutableAarch64") {
imageName = executableSpec.name.map { "$it-linux-aarch64" } imageName = executableSpec.name.map { "$it-linux-aarch64" }
mainClass = executableSpec.mainClass mainClass = executableSpec.mainClass
aarch64() aarch64()
@@ -120,8 +124,8 @@ val linuxExecutableAarch64 by
extraNativeImageArgs.add("-H:PageSize=65536") extraNativeImageArgs.add("-H:PageSize=65536")
} }
val alpineExecutableAmd64 by val alpineExecutableAmd64 =
tasks.registering(NativeImageBuild::class) { tasks.register<NativeImageBuild>("alpineExecutableAmd64") {
imageName = executableSpec.name.map { "$it-alpine-linux-amd64" } imageName = executableSpec.name.map { "$it-alpine-linux-amd64" }
mainClass = executableSpec.mainClass mainClass = executableSpec.mainClass
amd64() amd64()
@@ -129,17 +133,18 @@ val alpineExecutableAmd64 by
extraNativeImageArgs.addAll(listOf("--static", "--libc=musl")) extraNativeImageArgs.addAll(listOf("--static", "--libc=musl"))
} }
val windowsExecutableAmd64 by val windowsExecutableAmd64 =
tasks.registering(NativeImageBuild::class) { tasks.register<NativeImageBuild>("windowsExecutableAmd64") {
imageName = executableSpec.name.map { "$it-windows-amd64" } imageName = executableSpec.name.map { "$it-windows-amd64" }
mainClass = executableSpec.mainClass mainClass = executableSpec.mainClass
amd64() amd64()
setClasspath() setClasspath()
} }
val assembleNative by tasks.existing val assembleNative = tasks.named("assembleNative")
val testStartNativeExecutable by tasks.registering { val testStartNativeExecutable =
tasks.register("testStartNativeExecutable") {
dependsOn(assembleNative) dependsOn(assembleNative)
// dummy file for up-to-date checking // dummy file for up-to-date checking
@@ -168,7 +173,8 @@ val testStartNativeExecutable by tasks.registering {
val requiredGlibcVersion: Version = Version.parse("2.17") val requiredGlibcVersion: Version = Version.parse("2.17")
val checkGlibc by tasks.registering { val checkGlibc =
tasks.register("checkGlibc") {
enabled = buildInfo.os.isLinux && !buildInfo.musl enabled = buildInfo.os.isLinux && !buildInfo.musl
dependsOn(assembleNative) dependsOn(assembleNative)
doLast { doLast {
@@ -203,19 +209,24 @@ private fun <T : Task> Task.wraps(other: TaskProvider<T>) {
outputs.files(other) outputs.files(other)
} }
val testNative by tasks.existing { dependsOn(testStartNativeExecutable, checkGlibc) } val testNative = tasks.named("testNative") { dependsOn(testStartNativeExecutable, checkGlibc) }
val assembleNativeMacOsAarch64 by tasks.existing { wraps(macExecutableAarch64) } val assembleNativeMacOsAarch64 =
tasks.named("assembleNativeMacOsAarch64") { wraps(macExecutableAarch64) }
val assembleNativeMacOsAmd64 by tasks.existing { wraps(macExecutableAmd64) } val assembleNativeMacOsAmd64 = tasks.named("assembleNativeMacOsAmd64") { wraps(macExecutableAmd64) }
val assembleNativeLinuxAarch64 by tasks.existing { wraps(linuxExecutableAarch64) } val assembleNativeLinuxAarch64 =
tasks.named("assembleNativeLinuxAarch64") { wraps(linuxExecutableAarch64) }
val assembleNativeLinuxAmd64 by tasks.existing { wraps(linuxExecutableAmd64) } val assembleNativeLinuxAmd64 =
tasks.named("assembleNativeLinuxAmd64") { wraps(linuxExecutableAmd64) }
val assembleNativeAlpineLinuxAmd64 by tasks.existing { wraps(alpineExecutableAmd64) } val assembleNativeAlpineLinuxAmd64 =
tasks.named("assembleNativeAlpineLinuxAmd64") { wraps(alpineExecutableAmd64) }
val assembleNativeWindowsAmd64 by tasks.existing { wraps(windowsExecutableAmd64) } val assembleNativeWindowsAmd64 =
tasks.named("assembleNativeWindowsAmd64") { wraps(windowsExecutableAmd64) }
publishing { publishing {
publications { publications {
@@ -13,29 +13,31 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
val assembleNativeMacOsAarch64 by tasks.registering { group = "build" } val assembleNativeMacOsAarch64 = tasks.register("assembleNativeMacOsAarch64") { group = "build" }
val assembleNativeMacOsAmd64 by tasks.registering { group = "build" } val assembleNativeMacOsAmd64 = tasks.register("assembleNativeMacOsAmd64") { group = "build" }
val assembleNativeLinuxAarch64 by tasks.registering { group = "build" } val assembleNativeLinuxAarch64 = tasks.register("assembleNativeLinuxAarch64") { group = "build" }
val assembleNativeLinuxAmd64 by tasks.registering { group = "build" } val assembleNativeLinuxAmd64 = tasks.register("assembleNativeLinuxAmd64") { group = "build" }
val assembleNativeAlpineLinuxAmd64 by tasks.registering { group = "build" } val assembleNativeAlpineLinuxAmd64 =
tasks.register("assembleNativeAlpineLinuxAmd64") { group = "build" }
val assembleNativeWindowsAmd64 by tasks.registering { group = "build" } val assembleNativeWindowsAmd64 = tasks.register("assembleNativeWindowsAmd64") { group = "build" }
val testNativeMacOsAarch64 by tasks.registering { group = "verification" } val testNativeMacOsAarch64 = tasks.register("testNativeMacOsAarch64") { group = "verification" }
val testNativeMacOsAmd64 by tasks.registering { group = "verification" } val testNativeMacOsAmd64 = tasks.register("testNativeMacOsAmd64") { group = "verification" }
val testNativeLinuxAarch64 by tasks.registering { group = "verification" } val testNativeLinuxAarch64 = tasks.register("testNativeLinuxAarch64") { group = "verification" }
val testNativeLinuxAmd64 by tasks.registering { group = "verification" } val testNativeLinuxAmd64 = tasks.register("testNativeLinuxAmd64") { group = "verification" }
val testNativeAlpineLinuxAmd64 by tasks.registering { group = "verification" } val testNativeAlpineLinuxAmd64 =
tasks.register("testNativeAlpineLinuxAmd64") { group = "verification" }
val testNativeWindowsAmd64 by tasks.registering { group = "verification" } val testNativeWindowsAmd64 = tasks.register("testNativeWindowsAmd64") { group = "verification" }
val buildInfo = project.extensions.getByType<BuildInfo>() val buildInfo = project.extensions.getByType<BuildInfo>()
@@ -44,7 +46,8 @@ private fun <T : Task> Task.wraps(other: TaskProvider<T>) {
outputs.files(other) outputs.files(other)
} }
val assembleNative by tasks.registering { val assembleNative =
tasks.register("assembleNative") {
group = "build" group = "build"
if (!buildInfo.isCrossArchSupported && buildInfo.isCrossArch) { if (!buildInfo.isCrossArchSupported && buildInfo.isCrossArch) {
@@ -62,7 +65,8 @@ val assembleNative by tasks.registering {
wraps(assembleNativeLinuxAarch64) wraps(assembleNativeLinuxAarch64)
} }
buildInfo.os.isLinux && buildInfo.targetArch == "amd64" -> { buildInfo.os.isLinux && buildInfo.targetArch == "amd64" -> {
if (buildInfo.musl) wraps(assembleNativeAlpineLinuxAmd64) else wraps(assembleNativeLinuxAmd64) if (buildInfo.musl) wraps(assembleNativeAlpineLinuxAmd64)
else wraps(assembleNativeLinuxAmd64)
} }
buildInfo.os.isWindows && buildInfo.targetArch == "amd64" -> { buildInfo.os.isWindows && buildInfo.targetArch == "amd64" -> {
wraps(assembleNativeWindowsAmd64) wraps(assembleNativeWindowsAmd64)
@@ -77,7 +81,8 @@ val assembleNative by tasks.registering {
} }
} }
val testNative by tasks.registering { val testNative =
tasks.register("testNative") {
group = "verification" group = "verification"
dependsOn(assembleNative) dependsOn(assembleNative)
@@ -96,7 +101,8 @@ val testNative by tasks.registering {
dependsOn(testNativeLinuxAarch64) dependsOn(testNativeLinuxAarch64)
} }
buildInfo.os.isLinux && buildInfo.targetArch == "amd64" -> { buildInfo.os.isLinux && buildInfo.targetArch == "amd64" -> {
if (buildInfo.musl) dependsOn(testNativeAlpineLinuxAmd64) else dependsOn(testNativeLinuxAmd64) if (buildInfo.musl) dependsOn(testNativeAlpineLinuxAmd64)
else dependsOn(testNativeLinuxAmd64)
} }
buildInfo.os.isWindows && buildInfo.targetArch == "amd64" -> { buildInfo.os.isWindows && buildInfo.targetArch == "amd64" -> {
dependsOn(testNativeWindowsAmd64) dependsOn(testNativeWindowsAmd64)
@@ -111,12 +117,14 @@ val testNative by tasks.registering {
} }
} }
val checkNative by tasks.registering { val checkNative =
tasks.register("checkNative") {
group = "verification" group = "verification"
dependsOn(testNative) dependsOn(testNative)
} }
val buildNative by tasks.registering { val buildNative =
tasks.register("buildNative") {
group = "build" group = "build"
dependsOn(checkNative) dependsOn(checkNative)
} }
@@ -15,7 +15,7 @@
*/ */
plugins { id("com.diffplug.spotless") } plugins { id("com.diffplug.spotless") }
val pklFormatter by configurations.creating val pklFormatter = configurations.create("pklFormatter")
dependencies { pklFormatter(rootProject.project("pkl-formatter")) } dependencies { pklFormatter(rootProject.project("pkl-formatter")) }
+4 -3
View File
@@ -37,7 +37,8 @@ nexusPublishing {
} }
} }
val configureLateInitAnnotation by tasks.registering(ConfigureLateInitAnnotation::class) val configureLateInitAnnotation =
tasks.register<ConfigureLateInitAnnotation>("configureLateInitAnnotation")
idea { idea {
project { project {
@@ -53,9 +54,9 @@ idea {
} }
} }
val clean by tasks.existing { delete(layout.buildDirectory) } val clean = tasks.named("clean") { delete(layout.buildDirectory) }
val printVersion by tasks.registering { doFirst { println(buildInfo.pklVersion) } } val printVersion = tasks.register("printVersion") { doFirst { println(buildInfo.pklVersion) } }
val message = val message =
""" """
+3 -3
View File
@@ -83,8 +83,8 @@ tasks.shadowJar {
exclude("module-info.*") exclude("module-info.*")
} }
val testJavaExecutable by val testJavaExecutable =
tasks.registering(Test::class) { tasks.register<Test>("testJavaExecutable") {
testClassesDirs = tasks.test.get().testClassesDirs testClassesDirs = tasks.test.get().testClassesDirs
classpath = classpath =
// compiled test classes // compiled test classes
@@ -138,7 +138,7 @@ fun Exec.useRootDirAndSuppressOutput() {
// 0.28 Preparing for JDK21 toolchains revealed that `testStartJavaExecutable` may pass, even though // 0.28 Preparing for JDK21 toolchains revealed that `testStartJavaExecutable` may pass, even though
// the evaluator fails. To catch this, we eval a simple expression using the fat jar. // the evaluator fails. To catch this, we eval a simple expression using the fat jar.
val testEvalJavaExecutable by val testEvalJavaExecutable =
setupJavaExecutableRun("testEvalJavaExecutable", evalTestFlags) { useRootDirAndSuppressOutput() } setupJavaExecutableRun("testEvalJavaExecutable", evalTestFlags) { useRootDirAndSuppressOutput() }
// Run the same evaluator tests on all configured JDK test versions. // Run the same evaluator tests on all configured JDK test versions.
+3 -2
View File
@@ -19,10 +19,11 @@ plugins {
id("pklPublishLibrary") id("pklPublishLibrary")
} }
val svmClasspath: Configuration by configurations.creating val svmClasspath: Configuration = configurations.create("svmClasspath")
// used by pklNativeExecutable.gradle.kts // used by pklNativeExecutable.gradle.kts
@Suppress("unused") val svm: SourceSet by sourceSets.creating { compileClasspath = svmClasspath } @Suppress("unused")
val svm: SourceSet = sourceSets.create("svm") { compileClasspath = svmClasspath }
dependencies { dependencies {
api(projects.pklCore) api(projects.pklCore)
+5 -5
View File
@@ -37,7 +37,7 @@ dependencies {
* These packages are used by PackageServer to serve assets when running LanguageSnippetTests and * These packages are used by PackageServer to serve assets when running LanguageSnippetTests and
* PackageResolversTest. * PackageResolversTest.
*/ */
val createTestPackages by tasks.registering val createTestPackages = tasks.register("createTestPackages")
// make sure that declaring a dependency on this project suffices to have test fixtures generated // make sure that declaring a dependency on this project suffices to have test fixtures generated
tasks.processResources { tasks.processResources {
@@ -92,8 +92,8 @@ val keystoreName = "localhost.p12"
val keystoreFile = keystoreDir.map { it.file(keystoreName) } val keystoreFile = keystoreDir.map { it.file(keystoreName) }
val certsFileName = "localhost.pem" val certsFileName = "localhost.pem"
val generateKeys by val generateKeys =
tasks.registering(JavaExec::class) { tasks.register<JavaExec>("generateKeys") {
outputs.file(keystoreFile) outputs.file(keystoreFile)
mainClass.set("sun.security.tools.keytool.Main") mainClass.set("sun.security.tools.keytool.Main")
args = args =
@@ -117,8 +117,8 @@ val generateKeys by
} }
} }
val exportCerts by val exportCerts =
tasks.registering(JavaExec::class) { tasks.register<JavaExec>("exportCerts") {
val outputFile = keystoreDir.map { it.file(certsFileName) } val outputFile = keystoreDir.map { it.file(certsFileName) }
dependsOn(generateKeys) dependsOn(generateKeys)
inputs.file(keystoreFile) inputs.file(keystoreFile)
@@ -19,11 +19,11 @@ plugins {
id("pklPublishLibrary") id("pklPublishLibrary")
} }
val pklConfigJava: Configuration by configurations.creating val pklConfigJava: Configuration = configurations.create("pklConfigJava")
val pklConfigJavaAll: Configuration by configurations.creating val pklConfigJavaAll: Configuration = configurations.create("pklConfigJavaAll")
val pklCodegenKotlin: Configuration by configurations.creating val pklCodegenKotlin: Configuration = configurations.create("pklCodegenKotlin")
val buildInfo = project.extensions.getByType<BuildInfo>() val buildInfo = project.extensions.getByType<BuildInfo>()
@@ -49,8 +49,8 @@ dependencies {
testImplementation(libs.geantyref) testImplementation(libs.geantyref)
} }
val generateTestConfigClasses by val generateTestConfigClasses =
tasks.registering(JavaExec::class) { tasks.register<JavaExec>("generateTestConfigClasses") {
val outputDir = layout.buildDirectory.dir("testConfigClasses") val outputDir = layout.buildDirectory.dir("testConfigClasses")
outputs.dir(outputDir) outputs.dir(outputDir)
inputs.dir("src/test/resources/codegenPkl") inputs.dir("src/test/resources/codegenPkl")
+2 -1
View File
@@ -35,7 +35,8 @@ val externalReaderFixtureSourceSet: NamedDomainObjectProvider<SourceSet> =
runtimeClasspath += sourceSets.test.get().output + sourceSets.test.get().runtimeClasspath runtimeClasspath += sourceSets.test.get().output + sourceSets.test.get().runtimeClasspath
} }
val externalReaderFixtureImplementation: Configuration by configurations.getting { val externalReaderFixtureImplementation: Configuration =
configurations.getByName("externalReaderFixtureImplementation") {
extendsFrom(configurations.testImplementation.get()) extendsFrom(configurations.testImplementation.get())
} }
+4 -4
View File
@@ -78,8 +78,8 @@ tasks.test {
inputs.dir("src/test/files/SinglePackageTest/output") inputs.dir("src/test/files/SinglePackageTest/output")
} }
val testNativeExecutable by val testNativeExecutable =
tasks.registering(Test::class) { tasks.register<Test>("testNativeExecutable") {
dependsOn(tasks.assembleNative) dependsOn(tasks.assembleNative)
testClassesDirs = sourceSets.test.get().output.classesDirs testClassesDirs = sourceSets.test.get().output.classesDirs
classpath = sourceSets.test.get().runtimeClasspath classpath = sourceSets.test.get().runtimeClasspath
@@ -91,8 +91,8 @@ val testNativeExecutable by
filter { includeTestsMatching("org.pkl.doc.NativeExecutableTest") } filter { includeTestsMatching("org.pkl.doc.NativeExecutableTest") }
} }
val testJavaExecutable by val testJavaExecutable =
tasks.registering(Test::class) { tasks.register<Test>("testJavaExecutable") {
testClassesDirs = sourceSets.test.get().output.classesDirs testClassesDirs = sourceSets.test.get().output.classesDirs
classpath = sourceSets.test.get().runtimeClasspath classpath = sourceSets.test.get().runtimeClasspath
+6 -4
View File
@@ -23,8 +23,8 @@ plugins {
id("pklJSpecify") id("pklJSpecify")
} }
val pklDistributionCurrent: Configuration by configurations.creating val pklDistributionCurrent: Configuration = configurations.create("pklDistributionCurrent")
val pklHistoricalDistributions: Configuration by configurations.creating val pklHistoricalDistributions: Configuration = configurations.create("pklHistoricalDistributions")
// Because pkl-executor doesn't depend on other Pkl modules // Because pkl-executor doesn't depend on other Pkl modules
// (nor has overlapping dependencies that could cause a version conflict), // (nor has overlapping dependencies that could cause a version conflict),
@@ -66,7 +66,8 @@ publishing {
sourceSets { main { java { srcDir("src/main/java") } } } sourceSets { main { java { srcDir("src/main/java") } } }
val prepareHistoricalDistributions by tasks.registering { val prepareHistoricalDistributions =
tasks.register("prepareHistoricalDistributions") {
val outputDir = layout.buildDirectory.dir("pklHistoricalDistributions") val outputDir = layout.buildDirectory.dir("pklHistoricalDistributions")
inputs.files(pklHistoricalDistributions.files) inputs.files(pklHistoricalDistributions.files)
outputs.dir(outputDir) outputs.dir(outputDir)
@@ -95,7 +96,8 @@ val prepareHistoricalDistributions by tasks.registering {
} }
} }
val prepareTest by tasks.registering { val prepareTest =
tasks.register("prepareTest") {
dependsOn(pklDistributionCurrent, prepareHistoricalDistributions) dependsOn(pklDistributionCurrent, prepareHistoricalDistributions)
} }
+3 -3
View File
@@ -69,12 +69,12 @@ sourceSets {
// Then the path to the jar file and the toolchain's `java` binary // Then the path to the jar file and the toolchain's `java` binary
// are injected into tests as properties. // are injected into tests as properties.
val externalReader by sourceSets.creating {} val externalReader = sourceSets.create("externalReader") {}
dependencies { "externalReaderImplementation"(libs.msgpack) } dependencies { "externalReaderImplementation"(libs.msgpack) }
val externalReaderJar by val externalReaderJar =
tasks.registering(Jar::class) { tasks.register<Jar>("externalReaderJar") {
description = "Builds an external reader executable jar file" description = "Builds an external reader executable jar file"
archiveBaseName = "external-reader" archiveBaseName = "external-reader"
archiveVersion = "" archiveVersion = ""
+12 -12
View File
@@ -36,38 +36,38 @@ private fun Test.configureNativeTest() {
include("**/NativeServerTest.*") include("**/NativeServerTest.*")
} }
val testMacExecutableAarch64 by val testMacExecutableAarch64 =
tasks.registering(Test::class) { tasks.register<Test>("testMacExecutableAarch64") {
dependsOn(":pkl-cli:macExecutableAarch64") dependsOn(":pkl-cli:macExecutableAarch64")
configureNativeTest() configureNativeTest()
} }
val testMacExecutableAmd64 by val testMacExecutableAmd64 =
tasks.registering(Test::class) { tasks.register<Test>("testMacExecutableAmd64") {
dependsOn(":pkl-cli:macExecutableAmd64") dependsOn(":pkl-cli:macExecutableAmd64")
configureNativeTest() configureNativeTest()
} }
val testLinuxExecutableAmd64 by val testLinuxExecutableAmd64 =
tasks.registering(Test::class) { tasks.register<Test>("testLinuxExecutableAmd64") {
dependsOn(":pkl-cli:linuxExecutableAmd64") dependsOn(":pkl-cli:linuxExecutableAmd64")
configureNativeTest() configureNativeTest()
} }
val testLinuxExecutableAarch64 by val testLinuxExecutableAarch64 =
tasks.registering(Test::class) { tasks.register<Test>("testLinuxExecutableAarch64") {
dependsOn(":pkl-cli:linuxExecutableAarch64") dependsOn(":pkl-cli:linuxExecutableAarch64")
configureNativeTest() configureNativeTest()
} }
val testAlpineExecutableAmd64 by val testAlpineExecutableAmd64 =
tasks.registering(Test::class) { tasks.register<Test>("testAlpineExecutableAmd64") {
dependsOn(":pkl-cli:alpineExecutableAmd64") dependsOn(":pkl-cli:alpineExecutableAmd64")
configureNativeTest() configureNativeTest()
} }
val testWindowsExecutableAmd64 by val testWindowsExecutableAmd64 =
tasks.registering(Test::class) { tasks.register<Test>("testWindowsExecutableAmd64") {
dependsOn(":pkl-cli:windowsExecutableAmd64") dependsOn(":pkl-cli:windowsExecutableAmd64")
configureNativeTest() configureNativeTest()
} }
+8 -7
View File
@@ -25,9 +25,9 @@ plugins {
signing signing
} }
val placeholder: SourceSet by sourceSets.creating val placeholder = sourceSets.create("placeholder")
val firstPartySourcesJars by configurations.existing val firstPartySourcesJars = configurations.named("firstPartySourcesJars")
// Note: pkl-tools cannot (easily) contain pkl-config-kotlin // Note: pkl-tools cannot (easily) contain pkl-config-kotlin
// because pkl-tools ships with a shaded Kotlin stdlib. // because pkl-tools ships with a shaded Kotlin stdlib.
@@ -55,12 +55,13 @@ dependencies {
// TODO: need to figure out how to properly generate javadoc here. // TODO: need to figure out how to properly generate javadoc here.
// For now, we'll include a placeholder javadoc jar. // For now, we'll include a placeholder javadoc jar.
val javadocPlaceholder by tasks.registering(Javadoc::class) { source = placeholder.allJava } val javadocPlaceholder =
tasks.register<Javadoc>("javadocPlaceholder") { source = placeholder.allJava }
java { withJavadocJar() } java { withJavadocJar() }
val javadocJar by val javadocJar =
tasks.existing(Jar::class) { tasks.named<Jar>("javadocJar") {
from(javadocPlaceholder) from(javadocPlaceholder)
archiveBaseName.set("pkl-tools-all") archiveBaseName.set("pkl-tools-all")
archiveClassifier.set("javadoc") archiveClassifier.set("javadoc")
@@ -105,8 +106,8 @@ private fun Exec.configureTestStartFatJar(launcher: Provider<JavaLauncher>) {
} }
} }
val testStartFatJar by val testStartFatJar =
tasks.registering(Exec::class) { configureTestStartFatJar(buildInfo.javaTestLauncher) } tasks.register<Exec>("testStartFatJar") { configureTestStartFatJar(buildInfo.javaTestLauncher) }
tasks.validateFatJar { dependsOn(testStartFatJar) } tasks.validateFatJar { dependsOn(testStartFatJar) }
+2 -2
View File
@@ -24,8 +24,8 @@ plugins {
// create and publish a self-contained stdlib archive // create and publish a self-contained stdlib archive
// purpose is to provide non-jvm tools/projects with a versioned stdlib // purpose is to provide non-jvm tools/projects with a versioned stdlib
val stdlibZip by val stdlibZip =
tasks.registering(Zip::class) { tasks.register<Zip>("stdlibZip") {
destinationDirectory.set(layout.buildDirectory.dir("libs")) destinationDirectory.set(layout.buildDirectory.dir("libs"))
archiveBaseName.set("pkl-stdlib") archiveBaseName.set("pkl-stdlib")
archiveVersion.set(project.version as String) archiveVersion.set(project.version as String)