Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

misc: Upgrade to Kotlin 2.1.0 #123

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .brazil.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"dependencies": {
"org.jetbrains.kotlin:kotlin-stdlib:2.0.*": "KotlinStdlib-2.x",
"org.jetbrains.kotlin:kotlin-stdlib:2.*": "KotlinStdlib-2.x",
"org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.*": "KotlinxCoroutinesCoreJvm-1.x",
"org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.*": "KotlinxCoroutinesJdk8-1.x",
"software.amazon.awssdk.crt:aws-crt:0.*": "Aws-crt-java-1.0.x"
Expand Down
5 changes: 5 additions & 0 deletions .changes/337cca7e-6a38-4601-b5d2-9f8d12dd60f7.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"id": "337cca7e-6a38-4601-b5d2-9f8d12dd60f7",
"type": "misc",
"description": "Upgrade to Kotlin 2.1.0"
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Are we going to do a minor version bump of the CRT?

61 changes: 0 additions & 61 deletions aws-crt-kotlin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
import aws.sdk.kotlin.gradle.dsl.configurePublishing
import aws.sdk.kotlin.gradle.kmp.IDEA_ACTIVE
import aws.sdk.kotlin.gradle.kmp.configureKmpTargets

plugins {
Expand All @@ -24,42 +23,6 @@ configureKmpTargets()
kotlin {
explicitApi()

jvm {
attributes {
attribute<org.gradle.api.attributes.java.TargetJvmEnvironment>(
TargetJvmEnvironment.TARGET_JVM_ENVIRONMENT_ATTRIBUTE,
objects.named(TargetJvmEnvironment.STANDARD_JVM),
)
}
}

// KMP doesn't support sharing source sets for multiple JVM targets OR JVM + Android targets.
// We can manually declare a `jvmCommon` target and wire it up. It will compile fine but Intellij does
// not support this and the developer experience is abysmal. Kotlin/Native suffers a similar problem and
// we can use the same solution. Simply, if Intellij is running (i.e. the one invoking this script) then
// assume we are only building for JVM. Otherwise declare the additional JVM target for Android and
// set the sourceSet the same for both but with different runtime dependencies.
// See:
// * https://kotlinlang.org/docs/mpp-share-on-platforms.html#share-code-in-libraries
// * https://kotlinlang.org/docs/mpp-set-up-targets.html#distinguish-several-targets-for-one-platform
if (!IDEA_ACTIVE) {

// NOTE: We don't actually need the Android plugin. All of the Android specifics are handled in aws-crt-java,
// we just need a variant with a different dependency set + some distinguishing attributes.
jvm("android") {
attributes {
attribute(
org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType.Companion.attribute,
org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType.androidJvm,
)
attribute(
TargetJvmEnvironment.TARGET_JVM_ENVIRONMENT_ATTRIBUTE,
objects.named(TargetJvmEnvironment.ANDROID),
)
}
}
}
Comment on lines -47 to -61
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed because of:

e: Kotlin Target 'jvm()' is already declared.

Declaring multiple Kotlin Targets of the same type is not supported.

Read https://kotl.in/declaring-multiple-targets for details.


sourceSets {
val commonMain by getting {
dependencies {
Expand All @@ -83,30 +46,6 @@ kotlin {
implementation(libs.mockserver.netty)
}
}

if (!IDEA_ACTIVE) {
val androidMain by getting {
// re-use the jvm (desktop) sourceSet. We only really care about declaring a variant with a different set
// of runtime dependencies
kotlin.srcDir("jvm/src")
dependsOn(commonMain)
dependencies {
// we need symbols we can resolve during compilation but at runtime (i.e. on device) we depend on the Android dependency
compileOnly(libs.crt.java)
val crtJavaVersion = libs.versions.crt.java.version.get()
implementation("software.amazon.awssdk.crt:aws-crt-android:$crtJavaVersion@aar")

// FIXME - temporary integration with CompletableFuture while we work out a POC on the jvm target
implementation(libs.kotlinx.coroutines.jdk8)
}
}

// disable compilation of android test source set. It is the same as the jvmTest sourceSet/tests. This
// sourceSet only exists to create a new variant that is the same in every way except the runtime
// dependency on aws-crt-android. To test this we would need to run it on device/emulator.
tasks.getByName("androidTest").enabled = false
tasks.getByName("compileTestKotlinAndroid").enabled = false
}
}

sourceSets.all {
Expand Down
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ buildscript {
}

plugins {
id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.13.2"
alias(libs.plugins.kotlinx.binary.compatibility.validator)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

alias(libs.plugins.kotlin.multiplatform) apply false
alias(libs.plugins.aws.kotlin.repo.tools.kmp)
alias(libs.plugins.aws.kotlin.repo.tools.artifactsizemetrics)
Expand Down Expand Up @@ -54,7 +54,7 @@ subprojects {
if (project.typedProp<Boolean>("kotlinWarningsAsErrors") == true) {
allprojects {
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.allWarningsAsErrors = true
compilerOptions.allWarningsAsErrors = true
}
}
}
Expand Down
8 changes: 5 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
[versions]
kotlin-version = "2.0.21"
kotlin-version = "2.1.0"

aws-kotlin-repo-tools-version = "0.4.13"
aws-kotlin-repo-tools-version = "0.4.17"

# libs
crt-java-version = "0.31.3"
crt-java-version = "0.33.7"
coroutines-version = "1.9.0"
binary-compatibility-validator-version = "0.16.3"

# testing
junit-version = "5.10.1"
Expand Down Expand Up @@ -40,5 +41,6 @@ mockserver-netty = { module = "org.mock-server:mockserver-netty", version.ref =

[plugins]
kotlin-multiplatform = {id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin-version" }
kotlinx-binary-compatibility-validator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "binary-compatibility-validator-version" }
aws-kotlin-repo-tools-kmp = { id = "aws.sdk.kotlin.gradle.kmp", version.ref = "aws-kotlin-repo-tools-version" }
aws-kotlin-repo-tools-artifactsizemetrics = { id = "aws.sdk.kotlin.gradle.artifactsizemetrics", version.ref = "aws-kotlin-repo-tools-version" }
Loading