Skip to content

Commit

Permalink
chore: kotlin 2.1.0 update and misc refactorings
Browse files Browse the repository at this point in the history
  • Loading branch information
sureshg committed Dec 5, 2024
1 parent 00cbad7 commit d2f9ad7
Show file tree
Hide file tree
Showing 16 changed files with 222 additions and 111 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ reports
hs_err_pid*
classes.lst
*.jsa
*.aot*
jre/

# Kotlin
Expand Down
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Kotlin JVM & Multiplatform projects.

```bash
$ curl -s "https://get.sdkman.io" | bash
$ sdk i java 21.0.4-zulu
$ sdk u java 21.0.4-zulu
$ sdk i java 21.0.5-zulu
$ sdk u java 21.0.5-zulu
```

### Build & Testing
Expand Down Expand Up @@ -64,6 +64,16 @@ The next version will be based on the semantic version scope (`major`, `minor`,
| `dev.suresh.plugin.repos` | [![Maven Central](https://img.shields.io/maven-central/v/dev.suresh.plugin.repos/dev.suresh.plugin.repos.gradle.plugin?logo=gradle&logoColor=white&color=00B4E6)](https://repo1.maven.org/maven2/dev/suresh/plugin/) |
| `dev.suresh.plugin.catalog` | [![Maven Central](https://img.shields.io/maven-central/v/dev.suresh.plugin.catalog/dev.suresh.plugin.catalog.gradle.plugin?logo=gradle&logoColor=white&color=00B4E6)](https://repo1.maven.org/maven2/dev/suresh/plugin/) |

### Verifying Artifacts

The published artifacts are signed using this [key][signing_key]. The best way to verify artifacts
is [automatically with Gradle][gradle_verification].

[gradle_verification]: https://docs.gradle.org/current/userguide/dependency_verification.html#sec:signature-verification

[signing_key]: https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xc124db3a8ad1c13f7153decdf209c085c8b53ca1


<details>
<summary>Misc</summary>

Expand Down
124 changes: 70 additions & 54 deletions gradle/libs.versions.toml

Large diffs are not rendered by default.

68 changes: 68 additions & 0 deletions gradle/verification-keyring.keys
Original file line number Diff line number Diff line change
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U97N8gnAhci1PKEFAmKj
gZ4FCRhwDFMACgkQ8gnAhci1PKFvOQ//c37SvI561fxwt1TRWaqjD9YN8JejkxuV
B6nbOTFW+NIxEjXJ9Hs3ItjytAL7drEmtTMTFMfl4vQ3rCTC/UfbcSvdWm6rN5B6
vX/lIWMIpbCgPdu3xFF/OM2IrOlQ9JoEM9QClYBpb0K+cUgzEGoUCldTe2K9b2+x
nZ2BPJIQRLLidV/xceORK1nexsjfyuB0LKI+ciIzSzQ30c17bEvfE/DMxl0Mdp1q
sklB4n92Z0LoHGHYapwUavRHdH0hm4Oqx8GinQCQnOrk5RKLem8maf0MOTUEZDK0
1sCEmOQQT9qpBPdI5aL0cfnFAiqSH1l7uvhh2Czx7BXilvND28jNiD2i3uxDb1gA
AySvWegipyy72yYY33VZVtE1cmfLpf3Umu0HR248v21WdGBpsR1/dqm80rHvKpMN
mlcD3y7VEgv1M7tfyeL4Sz05K9xt/4QKG01KemrUyOVsYaQw9ytM7KItgzM5wzva
jWTGi919GskYONkOK8FW4BKrreAEKUSvJrHLPupeOdGQSTWHrZlG4eKpTGHIQcqc
s9JPzluo1wRHgz2jsNTIgKfnU6KMRGp93mUO1bTRB20kKrY6e0fx4cH7ZnU2mORD
zJzKC8o94FjJApb/gDrjKi+E/qCSoGLJYHdMLWytcnBa11AzA8Dk657p6YjY0wCA
yDpZeH4BAgg=
=R3uo
-----END PGP PUBLIC KEY BLOCK-----
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-rc-1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion plugins/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ dependencies {
// implementation(libs.jte.native)
// implementation(libs.build.kmp.hierarchy)
// implementation(libs.build.includegit.plugin)
// implementation(libs.build.cyclonedx.plugin)
// implementation(libs.build.dependencyanalysis)

testImplementation(gradleTestKit())
// For using kotlin-dsl in pre-compiled script plugins
Expand Down
12 changes: 8 additions & 4 deletions plugins/src/main/kotlin/common/Multiplatform.kt
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,7 @@ fun KotlinMultiplatformExtension.hostNativeTarget(configure: KotlinNativeTarget.
}

fun KotlinNativeCompilerOptions.configureKotlinNative() {
freeCompilerArgs.addAll(
// "-Xverbose-phases=Linker"
// "-Xruntime-logs=gc=info"
)
// freeCompilerArgs.addAll("-Xverbose-phases=Linker", "-Xruntime-logs=gc=info")
}

fun KotlinMultiplatformExtension.allNativeTargets(configure: KotlinNativeTarget.() -> Unit = {}) {
Expand All @@ -274,6 +271,13 @@ fun KotlinMultiplatformExtension.allNativeTargets(configure: KotlinNativeTarget.
configure()
}

compilerOptions {
optIn.addAll(
"kotlinx.cinterop.ExperimentalForeignApi",
"kotlin.experimental.ExperimentalNativeApi",
)
}

macosX64 { configureAll() }
macosArm64 { configureAll() }
linuxX64 { configureAll() }
Expand Down
3 changes: 3 additions & 0 deletions plugins/src/main/kotlin/common/PatchModuleArgProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import org.gradle.api.provider.Provider
import org.gradle.api.tasks.*
import org.gradle.process.CommandLineArgumentProvider

/**
* [Configure-With-JavaModules](https://kotlinlang.org/docs/gradle-configure-project.html#configure-with-java-modules-jpms-enabled)
*/
internal class PatchModuleArgProvider(
@get:Input val moduleName: Provider<String>,
@InputFiles @PathSensitive(PathSensitivity.RELATIVE) val kotlinClasses: Provider<Directory>,
Expand Down
13 changes: 9 additions & 4 deletions plugins/src/main/kotlin/common/ProjectExtns.kt
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,12 @@ fun Project.jvmArguments(appRun: Boolean = false, headless: Boolean = true) = bu
"-XX:+PrintCommandLineFlags",
"--enable-native-access=ALL-UNNAMED",
"--illegal-native-access=warn",
// "--sun-misc-unsafe-memory-access=warn",
"-Xmx128M",
"-XX:+UseZGC",
"-XX:+UseStringDeduplication",
"-XX:+UnlockExperimentalVMOptions",
"-XX:+UseCompactObjectHeaders",
"-XX:MaxRAMPercentage=0.8",
// "-XX:+UseEpsilonGC",
// "-XX:+AlwaysPreTouch",
Expand Down Expand Up @@ -242,6 +244,7 @@ fun Project.jvmArguments(appRun: Boolean = false, headless: Boolean = true) = bu
"-Djava.security.egd=file:/dev/./urandom",
"-Djdk.includeInExceptions=hostInfo,jar",
"-Dkotlinx.coroutines.debug",
"-Djdk.incubator.vector.VECTOR_ACCESS_OOB_CHECK=0",
"-Dcom.sun.management.jmxremote",
"-Dcom.sun.management.jmxremote.local.only=false",
"-Dcom.sun.management.jmxremote.port=9898",
Expand All @@ -259,7 +262,6 @@ fun Project.jvmArguments(appRun: Boolean = false, headless: Boolean = true) = bu
// "-XshowSettings:system",
// "-XshowSettings:properties",
// "--show-module-resolution",
// "-XX:+UseCompactObjectHeaders",
// "-XX:+ShowHiddenFrames",
// "-verbose:module",
// "-XX:ConcGCThreads=2",
Expand Down Expand Up @@ -390,29 +392,31 @@ fun KotlinCommonCompilerOptions.configureKotlinCommon(project: Project) =
apiVersion = kotlinApiVersion
languageVersion = kotlinLangVersion
progressiveMode = true
extraWarnings = false
allWarningsAsErrors = false
suppressWarnings = false
verbose = false
freeCompilerArgs.addAll(
"-Xexpect-actual-classes",
"-Xskip-prerelease-check",
"-Xwhen-guards",
"-Xmulti-dollar-interpolation",
"-Xnon-local-break-continue",
// "-XXLanguage:+ExplicitBackingFields",
// "-Xsuppress-version-warnings",
// "-P",
// "plugin:...=..."
)
optIn.addAll(
"kotlin.ExperimentalStdlibApi",
"kotlin.contracts.ExperimentalContracts",
"kotlin.ExperimentalUnsignedTypes",
"kotlin.contracts.ExperimentalContracts",
"kotlin.io.encoding.ExperimentalEncodingApi",
"kotlin.time.ExperimentalTime",
"kotlinx.coroutines.ExperimentalCoroutinesApi",
"kotlinx.serialization.ExperimentalSerializationApi",
"kotlin.ExperimentalMultiplatform",
"kotlin.js.ExperimentalJsExport",
"kotlin.experimental.ExperimentalNativeApi",
"kotlinx.cinterop.ExperimentalForeignApi",
"kotlin.uuid.ExperimentalUuidApi",
// "org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi",
)
Expand All @@ -430,6 +434,7 @@ fun KspAATask.configureKspConfig() =

/**
* JVM backend compiler options can be found in,
* - [CommonCompilerArgs](https://github.com/JetBrains/kotlin/blob/master/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt)
* - [K2JVMCompilerArguments.kt](https://github.com/JetBrains/kotlin/blob/master/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt)
* - [JvmTarget.kt](https://github.com/JetBrains/kotlin/blob/master/compiler/config.jvm/src/org/jetbrains/kotlin/config/JvmTarget.kt)
* - [ApiVersion.kt](https://github.com/JetBrains/kotlin/blob/master/compiler/util/src/org/jetbrains/kotlin/config/ApiVersion.kt#L35)
Expand Down
35 changes: 18 additions & 17 deletions plugins/src/main/kotlin/dev.suresh.plugin.graalvm.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ plugins {
}

val quickBuildEnabled = project.hasProperty("quick")
val nativeBundleEnabled = project.hasProperty("bundle")
val muslEnabled = project.hasProperty("musl")
val reportsEnabled = project.hasProperty("reports")
val agentEnabled = project.hasProperty("agent")
Expand All @@ -32,14 +31,19 @@ graalvmNative {
add("--enable-preview")
add("--enable-native-access=ALL-UNNAMED")
add("--native-image-info")
add("--color=auto")
add("--enable-monitoring=heapdump,jfr,jvmstat,threaddump,nmt")
add("--enable-https")
add("--install-exit-handlers")
add("-R:MaxHeapSize=64m")
add("-H:+ReportExceptionStackTraces")
add("-EBUILD_NUMBER=${project.version}")
add("-ECOMMIT_HASH=${semverExtn.commits.get().first().hash}")

add("-H:+UnlockExperimentalVMOptions")
add("-H:+VectorAPISupport")
add("-H:+CompactingOldGen")
add("-H:+ReportExceptionStackTraces")
add("-O3")
// add("-Os")
// add("-H:+ForeignAPISupport")
// add("--features=graal.aot.RuntimeFeature")
// add("-H:+AddAllCharsets")
// add("-H:+IncludeAllLocales")
Expand All @@ -48,10 +52,14 @@ graalvmNative {
// add("--enable-url-protocols=http,https,jar,unix")
// add("--initialize-at-build-time=kotlinx,kotlin,org.slf4j")

// Experimental options
add("-H:+UnlockExperimentalVMOptions")
add("-H:+CompactingOldGen")
add("-Os")
val monOpts = buildString {
append("heapdump,jfr,jvmstat,threaddump,nmt")
if (Platform.isUnix) {
append(",")
append("jcmd")
}
}
add("--enable-monitoring=$monOpts")

if (Platform.isLinux) {
when {
Expand All @@ -78,11 +86,6 @@ graalvmNative {
// add("--debug-attach")
}

if (nativeBundleEnabled) {
add("--bundle-create")
add("--dry-run")
}

if (java.toolchain.vendor.get().matches("Oracle.*")) {
if (reportsEnabled) {
add("-H:+BuildReport")
Expand All @@ -100,7 +103,8 @@ graalvmNative {
// }

jvmArgs = jvmArguments()
systemProperties = mapOf("java.awt.headless" to "false")
systemProperties =
mapOf("java.awt.headless" to "false", "jdk.incubator.vector.VECTOR_ACCESS_OOB_CHECK" to "0")
javaLauncher = javaToolchains.launcherFor { configureJvmToolchain(project) }
}

Expand Down Expand Up @@ -193,9 +197,6 @@ val niArchiveName
if (muslEnabled) {
append("static-")
}
if (nativeBundleEnabled) {
append("bundle-")
}
append(Platform.currentOS.id)
append("-")
append(Platform.currentArch.isa)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import com.diffplug.spotless.kotlin.KtfmtStep
import common.*
import java.time.Year
import org.hildan.github.changelog.plugin.GitHubChangelogExtension
Expand Down Expand Up @@ -89,11 +90,12 @@ spotless {
}
// if(plugins.hasPlugin(JavaPlugin::class.java)){ }

val ktfmtVersion = libs.versions.ktfmt.get()
val ktfmtVersion = maxOf(KtfmtStep.defaultVersion(), libs.versions.ktfmt.get())
kotlin {
ktfmt(ktfmtVersion)
target("src/**/*.kts", "src/**/*.kt")
trimTrailingWhitespace()
suppressLintsFor { step = "ktfmt" }
// licenseHeader(rootProject.file("gradle/license-header.txt"))
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import com.github.ajalt.mordant.rendering.TextColors
import com.google.cloud.tools.jib.gradle.BuildDockerTask
import com.google.devtools.ksp.gradle.KspAATask
import com.javiersc.kotlin.kopy.args.KopyFunctions
import common.*
import java.io.PrintWriter
import java.io.StringWriter
Expand All @@ -20,7 +21,7 @@ plugins {
kotlin("plugin.power-assert")
com.google.devtools.ksp
dev.zacsweers.redacted
// com.javiersc.kotlin.kopy
com.javiersc.kotlin.kopy
org.jetbrains.kotlinx.atomicfu
id("dev.suresh.plugin.kotlin.docs")
// kotlin("plugin.atomicfu")
Expand Down Expand Up @@ -75,7 +76,7 @@ redacted {
replacementString = ""
}

// kopy { functions = KopyFunctions.Copy }
kopy { functions = KopyFunctions.Copy }

// Java agent configuration for jib
val javaAgent by configurations.registering { isTransitive = false }
Expand Down
Loading

0 comments on commit d2f9ad7

Please sign in to comment.