mirror of
https://github.com/apple/pkl.git
synced 2026-04-10 10:53:40 +02:00
Clean up Kotlin code in buildSrc/ (#1512)
- fix most IntelliJ warnings (regex refactoring was done by IDE) - replace hardcoded JVM target versions with BuildInfo.jvmTarget
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
* 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.
|
||||
@@ -36,6 +36,7 @@ abstract class ExecutableJar : DefaultTask() {
|
||||
@get:Input abstract val jvmArgs: ListProperty<String>
|
||||
|
||||
@TaskAction
|
||||
@Suppress("unused")
|
||||
fun buildJar() {
|
||||
val inFile = inJar.get().asFile
|
||||
val outFile = outJar.get().asFile
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
* 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.
|
||||
@@ -57,7 +57,7 @@ open class MergeSourcesJars : DefaultTask() {
|
||||
// a word or a period character. should catch most cases.
|
||||
val importPattern =
|
||||
Pattern.compile(
|
||||
"(?<!(\\w|\\.))(" + relocatedPkgs.keys.joinToString("|") { it.replace(".", "\\.") } + ")"
|
||||
"(?<!([\\w.]))(" + relocatedPkgs.keys.joinToString("|") { it.replace(".", "\\.") } + ")"
|
||||
)
|
||||
|
||||
val sourceFileExts = sourceFileExtensions.get()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
* Copyright © 2025-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.
|
||||
@@ -102,6 +102,7 @@ abstract class NativeImageBuild : DefaultTask() {
|
||||
}
|
||||
|
||||
@TaskAction
|
||||
@Suppress("unused")
|
||||
protected fun run() {
|
||||
execOperations.exec {
|
||||
val exclusions =
|
||||
|
||||
@@ -52,14 +52,14 @@ configurations.all {
|
||||
}
|
||||
|
||||
plugins.withType(JavaPlugin::class).configureEach {
|
||||
tasks.withType<JavaCompile>().configureEach { options.release = 17 }
|
||||
tasks.withType<JavaCompile>().configureEach { options.release = buildInfo.jvmTarget }
|
||||
}
|
||||
|
||||
tasks.withType<KotlinJvmCompile>().configureEach {
|
||||
compilerOptions {
|
||||
jvmTarget = JvmTarget.JVM_17
|
||||
jvmTarget = JvmTarget.fromTarget(buildInfo.jvmTarget.toString())
|
||||
freeCompilerArgs.addAll("-Xjsr305=strict", "-Xjvm-default=all")
|
||||
freeCompilerArgs.add("-Xjdk-release=17")
|
||||
freeCompilerArgs.add("-Xjdk-release=${buildInfo.jvmTarget}")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,6 @@ tasks.withType(Test::class).configureEach {
|
||||
}
|
||||
debugOptions {
|
||||
enabled = System.getProperty("jvmdebug")?.toBoolean() ?: false
|
||||
@Suppress("UnstableApiUsage")
|
||||
host = "*"
|
||||
port = 5005
|
||||
suspend = true
|
||||
@@ -121,7 +120,6 @@ tasks.withType(Test::class).configureEach {
|
||||
tasks.withType(JavaExec::class).configureEach {
|
||||
debugOptions {
|
||||
enabled = System.getProperty("jvmdebug")?.toBoolean() ?: false
|
||||
@Suppress("UnstableApiUsage")
|
||||
host = "*"
|
||||
port = 5005
|
||||
suspend = true
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
* 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.
|
||||
@@ -21,6 +21,8 @@ tasks.addRule("Pattern: compatibilityTest[All|Releases|Latest|Candidate|Nightly|
|
||||
val taskName = this
|
||||
val matchResult = Regex("compatibilityTest(.+)").matchEntire(taskName) ?: return@addRule
|
||||
|
||||
// https://github.com/gradle/gradle/issues/32599
|
||||
@Suppress("DEPRECATION")
|
||||
when (val taskNameSuffix = matchResult.groupValues[1]) {
|
||||
"All" ->
|
||||
task("compatibilityTestAll") {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
* Copyright © 2025-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.
|
||||
@@ -72,7 +72,7 @@ fun Task.setupTestStartJavaExecutable(launcher: Provider<JavaLauncher>? = null)
|
||||
outputFile.get().asFile.toPath().apply {
|
||||
try {
|
||||
parent.createDirectories()
|
||||
} catch (ignored: java.nio.file.FileAlreadyExistsException) {}
|
||||
} catch (_: java.nio.file.FileAlreadyExistsException) {}
|
||||
writeText("OK")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
* Copyright © 2025-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.
|
||||
@@ -161,7 +161,7 @@ val testStartNativeExecutable by
|
||||
outputFile.get().asFile.toPath().apply {
|
||||
try {
|
||||
parent.createDirectories()
|
||||
} catch (ignored: java.nio.file.FileAlreadyExistsException) {}
|
||||
} catch (_: java.nio.file.FileAlreadyExistsException) {}
|
||||
writeText("OK")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user