Skip to content

Commit

Permalink
Update Kotlin and Compose Compiler to v2 (#697)
Browse files Browse the repository at this point in the history
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
  • Loading branch information
renovate[bot] authored May 27, 2024
1 parent 856473a commit 1b9cbb0
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 64 deletions.
16 changes: 3 additions & 13 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ios-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 5 additions & 15 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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/
docs/index.md
docs/changelog.md
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions compose/compose.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl

plugins {
alias(libs.plugins.fgp.multiplatform)
alias(libs.plugins.fgp.publish)
Expand All @@ -18,6 +20,7 @@ kotlin {
js(IR) {
nodejs()
}
@OptIn(ExperimentalWasmDsl::class)
wasmJs {
nodejs()
}
Expand Down
2 changes: 0 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 4 additions & 8 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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" }
Expand Down Expand Up @@ -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" }
Expand Down
57 changes: 37 additions & 20 deletions kotlinw
Original file line number Diff line number Diff line change
@@ -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}"
Expand All @@ -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}"
Expand All @@ -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" "--" "${@}"

0 comments on commit 1b9cbb0

Please sign in to comment.