From 1b9cbb065e81cc873729b5e5a0d4bbffe27eaa06 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 27 May 2024 09:23:49 +0200 Subject: [PATCH] Update Kotlin and Compose Compiler to v2 (#697) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/renovate.json5 | 16 ++------ .github/workflows/build.yml | 2 +- .github/workflows/ios-build.yml | 2 +- .github/workflows/publish-docs.yml | 2 +- .github/workflows/publish-release.yml | 2 +- .github/workflows/publish-snapshot.yml | 2 +- .gitignore | 20 +++------ build.gradle.kts | 2 +- compose/compose.gradle.kts | 3 ++ gradle.properties | 2 - gradle/libs.versions.toml | 12 ++---- kotlinw | 57 +++++++++++++++++--------- 12 files changed, 58 insertions(+), 64 deletions(-) diff --git a/.github/renovate.json5 b/.github/renovate.json5 index 6ca5bbea..6194a076 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5 @@ -41,26 +41,16 @@ matchPackagePatterns: [ "org.jetbrains.kotlin", "com.google.devtools.ksp", - "dev.zacsweers.kctfork", - "androidx.compose.compiler", - "org.jetbrains.compose.compiler", ], excludePackagePatterns: [ "org.jetbrains.kotlinx", ], - groupName: "Kotlin and Compose Compiler" + groupName: "Kotlin and KSP" }, { matchPackagePatterns: [ - "androidx.compose.runtime", - "androidx.compose.ui", - "androidx.compose.foundation", - "androidx.compose.material", - "org.jetbrains.compose$", - "org.jetbrains.compose.runtime", - "org.jetbrains.compose.ui", - "org.jetbrains.compose.foundation", - "org.jetbrains.compose.material", + "androidx.compose", + "org.jetbrains.compose", ], groupName: "Compose" } diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index aa2f1e94..8d26730f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,7 +19,7 @@ jobs: uses: actions/setup-java@v4 with: distribution: zulu - java-version: 19 + java-version: 22 - uses: gradle/actions/setup-gradle@v3 with: diff --git a/.github/workflows/ios-build.yml b/.github/workflows/ios-build.yml index f0c56152..3395ad50 100644 --- a/.github/workflows/ios-build.yml +++ b/.github/workflows/ios-build.yml @@ -19,7 +19,7 @@ jobs: uses: actions/setup-java@v4 with: distribution: zulu - java-version: 19 + java-version: 22 - name: Setup Xcode uses: maxim-lobanov/setup-xcode@v1.6.0 diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml index c79cdcab..37beeb09 100644 --- a/.github/workflows/publish-docs.yml +++ b/.github/workflows/publish-docs.yml @@ -35,7 +35,7 @@ jobs: uses: actions/setup-java@v4 with: distribution: zulu - java-version: 19 + java-version: 22 - name: Install Android SDK run: ./.github/android-sdk.sh diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 48ec7386..afa177c8 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -19,7 +19,7 @@ jobs: uses: actions/setup-java@v4 with: distribution: zulu - java-version: 19 + java-version: 22 - name: Install Android SDK run: ./.github/android-sdk.sh diff --git a/.github/workflows/publish-snapshot.yml b/.github/workflows/publish-snapshot.yml index ae8d276c..c8f489b6 100644 --- a/.github/workflows/publish-snapshot.yml +++ b/.github/workflows/publish-snapshot.yml @@ -23,7 +23,7 @@ jobs: uses: actions/setup-java@v4 with: distribution: zulu - java-version: 19 + java-version: 22 - name: Install Android SDK run: ./.github/android-sdk.sh diff --git a/.gitignore b/.gitignore index 25615b66..620c0028 100644 --- a/.gitignore +++ b/.gitignore @@ -1,20 +1,10 @@ -*.iml .gradle -/local.properties -/.idea/libraries -/.idea/modules.xml -/.idea/workspace.xml +.idea +local.properties .DS_Store build/ -/captures -.externalNativeBuild -out/ kotlin-js-store/ +.kotlin/ -.idea* -*.thumbnails -.python-version - - -.java-version -.vscode/ \ No newline at end of file +docs/index.md +docs/changelog.md diff --git a/build.gradle.kts b/build.gradle.kts index 0b345acd..146b7cdc 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,7 +2,7 @@ plugins { alias(libs.plugins.kotlin.multiplatform).apply(false) alias(libs.plugins.android.app).apply(false) alias(libs.plugins.android.library).apply(false) - alias(libs.plugins.jetbrains.compose).apply(false) + alias(libs.plugins.compose).apply(false) alias(libs.plugins.dependency.analysis).apply(false) alias(libs.plugins.dokka).apply(false) alias(libs.plugins.publish).apply(false) diff --git a/compose/compose.gradle.kts b/compose/compose.gradle.kts index 076dbfb4..88f812c0 100644 --- a/compose/compose.gradle.kts +++ b/compose/compose.gradle.kts @@ -1,3 +1,5 @@ +import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl + plugins { alias(libs.plugins.fgp.multiplatform) alias(libs.plugins.fgp.publish) @@ -18,6 +20,7 @@ kotlin { js(IR) { nodejs() } + @OptIn(ExperimentalWasmDsl::class) wasmJs { nodejs() } diff --git a/gradle.properties b/gradle.properties index f76ef3ae..9e057065 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,9 +3,7 @@ org.gradle.parallel=true android.useAndroidX=true -kotlin.mpp.stability.nowarn=true kotlin.native.ignoreDisabledTargets=true -kapt.includeCompileClasspath=false dependency.analysis.print.build.health=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 0acc22cf..645669cf 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,23 +1,21 @@ [versions] -kotlin = "1.9.24" +kotlin = "2.0.0" coroutines = "1.8.1" -java-target = "1.8" -java-toolchain = "19" +java-target = "11" +java-toolchain = "22" android-gradle = "8.4.1" android-min = "21" android-target = "34" android-compile = "34" -androidx-compose-compiler = "1.5.14" androidx-compose-runtime = "1.6.7" androidx-compose-ui = "1.6.7" androidx-compose-foundation = "1.6.7" androidx-compose-material = "1.6.7" androidx-compose-material3 = "1.2.1" jetbrains-compose = "1.6.2" -jetbrains-compose-compiler = "1.5.14" androidx-activity = "1.9.0" androidx-annotation = "1.8.0" @@ -51,14 +49,12 @@ kotlin-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" } coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" } -androidx-compose-compiler = { module = "androidx.compose.compiler:compiler", version.ref = "androidx-compose-compiler" } androidx-compose-runtime = { module = "androidx.compose.runtime:runtime", version.ref = "androidx-compose-runtime" } androidx-compose-ui = { module = "androidx.compose.ui:ui", version.ref = "androidx-compose-ui" } androidx-compose-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "androidx-compose-foundation" } androidx-compose-material = { module = "androidx.compose.material:material", version.ref = "androidx-compose-material" } androidx-compose-material3 = { module = "androidx.compose.material3:material3", version.ref = "androidx-compose-material3" } jetbrains-compose-runtime = { module = "org.jetbrains.compose.runtime:runtime", version.ref = "jetbrains-compose" } -jetbrains-compose-compiler = { module = "org.jetbrains.compose.compiler:compiler", version.ref = "jetbrains-compose-compiler" } androidx-activity = { module = "androidx.activity:activity", version.ref = "androidx-activity" } androidx-annotation = { module = "androidx.annotation:annotation", version.ref = "androidx-annotation" } @@ -94,7 +90,7 @@ android-app = { id = "com.android.application", version.ref = "android-gradle" } android-library = { id = "com.android.library", version.ref = "android-gradle" } kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } -jetbrains-compose = { id = "org.jetbrains.compose", version.ref = "jetbrains-compose" } +compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } publish = { id = "com.vanniktech.maven.publish", version.ref = "publish" } dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" } binarycompatibility = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "binarycompatibility" } diff --git a/kotlinw b/kotlinw index 135d90d9..fde6551d 100755 --- a/kotlinw +++ b/kotlinw @@ -1,32 +1,40 @@ -#!/usr/bin/env bash +#!/bin/sh set -e -ROOT_DIR="$(dirname $0)" +ROOT_DIR="$(dirname "$0")" -JDK_VERSION="$(grep -s 'java-gradle' $ROOT_DIR/gradle/libs.versions.toml | cut -d'"' -f2)" +JDK_VERSION="$(grep -s 'java-gradle' "$ROOT_DIR/gradle/libs.versions.toml" | cut -d'"' -f2)" if [ -z "$JDK_VERSION" ]; then - JDK_VERSION="19" + JDK_VERSION="22" fi -KOTLIN_VERSION="1.9.0" +KOTLIN_VERSION="$(grep -s -m 1 '^kotlin \?=' "$ROOT_DIR/gradle/libs.versions.toml" | cut -d'"' -f2)" if [ -f "$ROOT_DIR/gradle/libs.versions.toml" ]; then - KOTLIN_VERSION="$(grep -m 1 '^kotlin \?=' $ROOT_DIR/gradle/libs.versions.toml | cut -d'"' -f2)" + KOTLIN_VERSION="2.0.0" fi -INSTALLATION_DIR="${HOME}/.kotlinw/${KOTLIN_VERSION}" -BINARY_DIR="${INSTALLATION_DIR}/kotlinc/bin" +# OS specific support (must be 'true' or 'false'). +case "$(uname -s)" in + Linux*) MACHINE=Linux;; + Darwin*) MACHINE=Mac;; + *) MACHINE="UNSUPPORTED" +esac -if [[ "$OSTYPE" == "linux-gnu"* ]]; then - if [ -d "/usr/lib/jvm/zulu-$JDK_VERSION-amd64" ]; then - JAVA_HOME="/usr/lib/jvm/zulu-$JDK_VERSION-amd64/" - elif [ -d "/usr/lib/jvm/zulu$JDK_VERSION-ca-amd64" ]; then - JAVA_HOME="/usr/lib/jvm/zulu$JDK_VERSION-ca-amd64/" - else - java --version +if [ "$MACHINE" = "Linux" ]; then + export JAVA_HOME="/usr/lib/jvm/zulu-$JDK_VERSION-amd64/" + if [ ! -d "$JAVA_HOME" ]; then + export JAVA_HOME="/usr/lib/jvm/zulu$JDK_VERSION-ca-amd64/" + if [ ! -d "$JAVA_HOME" ]; then + echo "Installing JDK ${JDK_VERSION} (you may be prompted for your password)..." + curl -s https://repos.azul.com/azul-repo.key | sudo gpg --batch --yes --dearmor -o /usr/share/keyrings/azul.gpg + echo "deb [signed-by=/usr/share/keyrings/azul.gpg] https://repos.azul.com/zulu/deb stable main" | sudo tee /etc/apt/sources.list.d/zulu.list + sudo apt update + sudo apt install -y "zulu$JDK_VERSION-jdk" + fi fi -elif [[ "$OSTYPE" == "darwin"* ]]; then - JAVA_HOME="/Library/Java/JavaVirtualMachines/zulu-$JDK_VERSION.jdk/Contents/Home" - if [ ! -d "/Library/Java/JavaVirtualMachines/zulu-${JDK_VERSION}.jdk/Contents/Home" ]; then +elif [ "$MACHINE" = "Mac" ]; then + export JAVA_HOME="/Library/Java/JavaVirtualMachines/zulu-$JDK_VERSION.jdk/Contents/Home" + if [ ! -d "$JAVA_HOME" ]; then echo "Installing JDK ${JDK_VERSION} (you may be prompted for your password)..." brew tap mdogan/zulu brew install --cask "zulu-jdk${JDK_VERSION}" @@ -36,9 +44,12 @@ else exit 1 fi +INSTALLATION_DIR="${HOME}/.kotlinw/${KOTLIN_VERSION}" +BINARY_DIR="${INSTALLATION_DIR}/kotlinc/bin" + if [ ! -f "${BINARY_DIR}/kotlin" ]; then echo "Downloading Kotlin ${KOTLIN_VERSION}" - mkdir -p ${INSTALLATION_DIR} + mkdir -p "${INSTALLATION_DIR}" temp_file=$(mktemp /tmp/kotlin.zip.XXXXXX) curl -sLo "${temp_file}" "https://github.com/JetBrains/kotlin/releases/download/v${KOTLIN_VERSION}/kotlin-compiler-${KOTLIN_VERSION}.zip" unzip -q "${temp_file}" -d "${INSTALLATION_DIR}" @@ -48,4 +59,10 @@ fi # this works around an issue where the Kotlin compiler used by ktlint accesses code that JDK 12+ don't allow access to export JAVA_OPTS="--add-opens java.base/java.lang=ALL-UNNAMED" -"${BINARY_DIR}/kotlin" "$@" +SCRIPT_FILE="$1" +# will remove the first element of the $@ arguments array since we read it already above +shift +# uses kotlinc instead of kotlin because the latter doesn't allow specifying a jvm target and defaults to Java 8 +# the -- between SCRIPT_FILE and the other arguments is there so that the arguments are treated as arguments to the +# script and not to kotlinc +"${BINARY_DIR}/kotlinc" "-jvm-target" "$JDK_VERSION" "-script" "$SCRIPT_FILE" "--" "${@}"