mirror of
https://github.com/apple/pkl.git
synced 2026-05-25 16:19:20 +02:00
2d4286ee7b
Motivation - Enable correct NullAway analysis - Pick up toolchain fixes and improvements Toolchains - Require JDK 25 for JVM toolchain (keep Java 17 runtime compatibility) - Require Kotlin 2.3.20 for Kotlin toolchain (keep Kotlin 2.2 runtime compatibility) - Require JDK 25 for Gradle daemon JVM (via gradle-daemon-jvm.properties) - Fix javac and kotlinc warnings from toolchain upgrades CI - Bump GitHub workflows to JDK 25 Building Kotlin - Bump Kotlin language level to 2.2 to match stdlib version - Consolidate build logic into pklKotlinBase.gradle.kts - Adopt modern Kotlin plugin syntax - Fix new kotlinc warnings - Update ktfmt to 0.62 - first version compatible with Kotlin 2.3.20 - changes formatting compared to 0.61 - Replace dependency resolution rule with BOM alignment - rule was too broad and interfered with toolchain/runtime separation Testing - Expand matrix to JDK 25 (LTS) and 26 - Ensure each matrix task can be run independently - Fix KotlinCodeGeneratorsTest and EmbeddedExecutorsTest on affected JDKs - Disable one test in CliCommandTest on affected JDKs (failure cause unknown) Compatibility fixes - Fix reflective access in DocGenerator on affected JDKs Build fixes - Fix misuse of `task.enabled` vs. `report.required` - Fix `gradlew tasks` on Windows - Downgrade Spotless to 8.3.0 to (hopefully) work around sporadic NoClassDefFoundError Result - NullAway runs correctly - Broader JDK test coverage - More reproducible and potentially faster builds
122 lines
3.8 KiB
Kotlin
122 lines
3.8 KiB
Kotlin
/*
|
|
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* https://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
@file:Suppress("HttpUrlsUsage", "unused")
|
|
|
|
import org.gradle.accessors.dm.LibrariesForLibs
|
|
|
|
plugins {
|
|
`java-library`
|
|
`jvm-toolchains`
|
|
`jvm-test-suite`
|
|
id("pklKotlinTest")
|
|
id("com.diffplug.spotless")
|
|
}
|
|
|
|
// make sources Jar available to other subprojects
|
|
val sourcesJarConfiguration: Provider<Configuration> = configurations.register("sourcesJar")
|
|
|
|
// Version Catalog library symbols.
|
|
val libs = the<LibrariesForLibs>()
|
|
|
|
// Build configuration.
|
|
val info = project.extensions.getByType<BuildInfo>()
|
|
|
|
java {
|
|
withSourcesJar() // creates `sourcesJar` task
|
|
withJavadocJar()
|
|
|
|
toolchain {
|
|
languageVersion = info.jdkToolchainVersion
|
|
vendor = info.jdkVendor
|
|
}
|
|
}
|
|
|
|
artifacts {
|
|
// make sources Jar available to other subprojects
|
|
add("sourcesJar", tasks["sourcesJar"])
|
|
}
|
|
|
|
spotless {
|
|
val revertYearOnlyChanges = RevertYearOnlyChangesStep(rootProject.rootDir, ratchetFrom!!).create()
|
|
|
|
java {
|
|
addStep(revertYearOnlyChanges)
|
|
googleJavaFormat(libs.versions.googleJavaFormat.get())
|
|
target("src/*/java/**/*.java")
|
|
licenseHeaderFile(rootProject.file("buildSrc/src/main/resources/license-header.star-block.txt"))
|
|
}
|
|
}
|
|
|
|
tasks.jar {
|
|
manifest {
|
|
attributes +=
|
|
mapOf(
|
|
"Automatic-Module-Name" to "org.${project.name.replace("-", ".")}",
|
|
"Add-Exports" to info.jpmsExportsForJarManifest,
|
|
)
|
|
}
|
|
}
|
|
|
|
tasks.javadoc {
|
|
classpath = sourceSets.main.get().output + sourceSets.main.get().compileClasspath
|
|
source = sourceSets.main.get().allJava
|
|
title = "${project.name} ${project.version} API"
|
|
(options as StandardJavadocDocletOptions).addStringOption("Xdoclint:none", "-quiet")
|
|
}
|
|
|
|
val truffleJavacArgs =
|
|
listOf(
|
|
// TODO: determine correct limits for Truffle specializations
|
|
// (see https://graalvm.slack.com/archives/CNQSB2DHD/p1712380902746829)
|
|
"-Atruffle.dsl.SuppressWarnings=truffle-limit"
|
|
)
|
|
|
|
tasks.compileJava {
|
|
javaCompiler = info.javaCompiler
|
|
options.compilerArgs.addAll(truffleJavacArgs + info.jpmsAddModulesFlags)
|
|
}
|
|
|
|
tasks.withType<JavaCompile>().configureEach {
|
|
javaCompiler = info.javaCompiler
|
|
options.release = info.jvmTarget
|
|
}
|
|
|
|
tasks.withType<JavaExec>().configureEach { jvmArgs(info.jpmsAddModulesFlags) }
|
|
|
|
fun Test.configureJdkTestTask(launcher: Provider<JavaLauncher>) {
|
|
useJUnitPlatform()
|
|
javaLauncher = launcher
|
|
systemProperties.putAll(info.testProperties)
|
|
jvmArgs.addAll(info.jpmsAddModulesFlags)
|
|
}
|
|
|
|
tasks.test { configureJdkTestTask(info.javaTestLauncher) }
|
|
|
|
// Prepare test tasks for each JDK version which is within the test target suite for Pkl. Each task
|
|
// uses a pinned JDK toolchain version, and is named for the major version which is tested.
|
|
//
|
|
// Test tasks configured in this manner are executed manually by name, e.g. `./gradlew testJdk11`,
|
|
// and automatically as dependencies of `check`.
|
|
//
|
|
// We omit the current JDK from this list because it is already tested, in effect, by the default
|
|
// `test` task.
|
|
//
|
|
// Pkl subprojects may elect to further configure these tasks as needed; by default, each task
|
|
// inherits the configuration of the default `test` task (aside from an overridden launcher).
|
|
val jdkTestTasks = info.multiJdkTestingWith(tasks.test) { (_, jdk) -> configureJdkTestTask(jdk) }
|
|
|
|
tasks.check { dependsOn(jdkTestTasks) }
|