mirror of
https://github.com/apple/pkl.git
synced 2026-07-08 14:05:17 +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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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>
|
@get:Input abstract val jvmArgs: ListProperty<String>
|
||||||
|
|
||||||
@TaskAction
|
@TaskAction
|
||||||
|
@Suppress("unused")
|
||||||
fun buildJar() {
|
fun buildJar() {
|
||||||
val inFile = inJar.get().asFile
|
val inFile = inJar.get().asFile
|
||||||
val outFile = outJar.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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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.
|
// a word or a period character. should catch most cases.
|
||||||
val importPattern =
|
val importPattern =
|
||||||
Pattern.compile(
|
Pattern.compile(
|
||||||
"(?<!(\\w|\\.))(" + relocatedPkgs.keys.joinToString("|") { it.replace(".", "\\.") } + ")"
|
"(?<!([\\w.]))(" + relocatedPkgs.keys.joinToString("|") { it.replace(".", "\\.") } + ")"
|
||||||
)
|
)
|
||||||
|
|
||||||
val sourceFileExts = sourceFileExtensions.get()
|
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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -102,6 +102,7 @@ abstract class NativeImageBuild : DefaultTask() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@TaskAction
|
@TaskAction
|
||||||
|
@Suppress("unused")
|
||||||
protected fun run() {
|
protected fun run() {
|
||||||
execOperations.exec {
|
execOperations.exec {
|
||||||
val exclusions =
|
val exclusions =
|
||||||
|
|||||||
@@ -52,14 +52,14 @@ configurations.all {
|
|||||||
}
|
}
|
||||||
|
|
||||||
plugins.withType(JavaPlugin::class).configureEach {
|
plugins.withType(JavaPlugin::class).configureEach {
|
||||||
tasks.withType<JavaCompile>().configureEach { options.release = 17 }
|
tasks.withType<JavaCompile>().configureEach { options.release = buildInfo.jvmTarget }
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<KotlinJvmCompile>().configureEach {
|
tasks.withType<KotlinJvmCompile>().configureEach {
|
||||||
compilerOptions {
|
compilerOptions {
|
||||||
jvmTarget = JvmTarget.JVM_17
|
jvmTarget = JvmTarget.fromTarget(buildInfo.jvmTarget.toString())
|
||||||
freeCompilerArgs.addAll("-Xjsr305=strict", "-Xjvm-default=all")
|
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 {
|
debugOptions {
|
||||||
enabled = System.getProperty("jvmdebug")?.toBoolean() ?: false
|
enabled = System.getProperty("jvmdebug")?.toBoolean() ?: false
|
||||||
@Suppress("UnstableApiUsage")
|
|
||||||
host = "*"
|
host = "*"
|
||||||
port = 5005
|
port = 5005
|
||||||
suspend = true
|
suspend = true
|
||||||
@@ -121,7 +120,6 @@ tasks.withType(Test::class).configureEach {
|
|||||||
tasks.withType(JavaExec::class).configureEach {
|
tasks.withType(JavaExec::class).configureEach {
|
||||||
debugOptions {
|
debugOptions {
|
||||||
enabled = System.getProperty("jvmdebug")?.toBoolean() ?: false
|
enabled = System.getProperty("jvmdebug")?.toBoolean() ?: false
|
||||||
@Suppress("UnstableApiUsage")
|
|
||||||
host = "*"
|
host = "*"
|
||||||
port = 5005
|
port = 5005
|
||||||
suspend = true
|
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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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 taskName = this
|
||||||
val matchResult = Regex("compatibilityTest(.+)").matchEntire(taskName) ?: return@addRule
|
val matchResult = Regex("compatibilityTest(.+)").matchEntire(taskName) ?: return@addRule
|
||||||
|
|
||||||
|
// https://github.com/gradle/gradle/issues/32599
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
when (val taskNameSuffix = matchResult.groupValues[1]) {
|
when (val taskNameSuffix = matchResult.groupValues[1]) {
|
||||||
"All" ->
|
"All" ->
|
||||||
task("compatibilityTestAll") {
|
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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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 {
|
outputFile.get().asFile.toPath().apply {
|
||||||
try {
|
try {
|
||||||
parent.createDirectories()
|
parent.createDirectories()
|
||||||
} catch (ignored: java.nio.file.FileAlreadyExistsException) {}
|
} catch (_: java.nio.file.FileAlreadyExistsException) {}
|
||||||
writeText("OK")
|
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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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 {
|
outputFile.get().asFile.toPath().apply {
|
||||||
try {
|
try {
|
||||||
parent.createDirectories()
|
parent.createDirectories()
|
||||||
} catch (ignored: java.nio.file.FileAlreadyExistsException) {}
|
} catch (_: java.nio.file.FileAlreadyExistsException) {}
|
||||||
writeText("OK")
|
writeText("OK")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user