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.0.0 #1105

Merged
merged 40 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
9c769f3
latest
lauzadis Apr 12, 2024
0fee903
latest
lauzadis Apr 15, 2024
da64f87
latest
lauzadis Apr 15, 2024
0ab6533
latest
lauzadis Apr 15, 2024
b9d1626
Merge branch 'main' of github.com:smithy-lang/smithy-kotlin into misc…
lauzadis May 23, 2024
9de13a4
Compiles
lauzadis May 25, 2024
35b6157
changelog
lauzadis May 25, 2024
09fa097
Take full dependency, not RC
lauzadis May 25, 2024
4179c4e
Merge branch 'main' of github.com:smithy-lang/smithy-kotlin into misc…
lauzadis Jun 14, 2024
f6cc850
upgrade to 0.4.7
lauzadis Jun 17, 2024
e4d5aa3
upgrade coroutines and atomicfu too
lauzadis Jun 20, 2024
ad72554
ktlint
lauzadis Jun 20, 2024
9f35f07
atomicfu plugin only needs to be applied in the top-level build file
lauzadis Jun 20, 2024
184e0d3
Revert "atomicfu plugin only needs to be applied in the top-level bui…
lauzadis Jun 20, 2024
bcc160b
Fix jvmAndNative source set
lauzadis Jun 21, 2024
a510dde
Fix deprecation warning
lauzadis Jun 21, 2024
03ec8a7
ktlint
lauzadis Jun 21, 2024
3f46eb9
remove comment
lauzadis Jun 21, 2024
3cc38d3
Typealias no longer works :(
lauzadis Jun 21, 2024
ae7239f
passes now... ¯\_(ツ)_/¯
lauzadis Jun 21, 2024
4f21bf9
`BigDecimal` needs to override `equals` function to get tests passing
lauzadis Jun 21, 2024
195419c
apiDump
lauzadis Jun 21, 2024
46f19a9
Upgrade kotlin-compile-testing and optin to their new `ExperimentalCo…
lauzadis Jun 21, 2024
fef00b0
Fix implementation of `equals` in `BigIntegerJvm`
lauzadis Jun 21, 2024
2ef4539
ktlint
lauzadis Jun 21, 2024
d667f30
Upgrade to snapshot plugin version
lauzadis Jun 21, 2024
c82dc97
Upgrade to latest aws-kotlin-repo-tools plugin
lauzadis Jun 21, 2024
c93b3aa
Fix compiler warning
lauzadis Jun 21, 2024
018e2cf
disable `kotlinWarningsAsErrors` for all-platforms CI
lauzadis Jun 21, 2024
070858f
disable `kotlinWarningsAsErrors` for all-platforms CI
lauzadis Jun 21, 2024
c3b4247
Merge branch 'main' of github.com:smithy-lang/smithy-kotlin into misc…
lauzadis Jun 21, 2024
b3316a9
Latest package transformation config
lauzadis Jun 21, 2024
3120167
Share value
lauzadis Jun 26, 2024
8ade075
remove comment
lauzadis Jun 26, 2024
f3a6ecb
reverted
lauzadis Jun 26, 2024
aa82a1f
Merge branch 'main' of github.com:smithy-lang/smithy-kotlin into misc…
lauzadis Jul 12, 2024
ab46ea8
merge from main
lauzadis Jul 12, 2024
c91ec04
Merge branch 'main' of github.com:smithy-lang/smithy-kotlin into misc…
lauzadis Jul 12, 2024
d7ef91b
latest
lauzadis Jul 15, 2024
b482091
Merge branch 'main' of github.com:smithy-lang/smithy-kotlin into misc…
lauzadis Jul 24, 2024
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
49 changes: 15 additions & 34 deletions .brazil.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
{
"dependencies": {
"com.squareup.okhttp3:okhttp-coroutines-jvm:5.*": "OkHttp3CoroutinesJvm-5.x",
"com.squareup.okhttp3:okhttp-coroutines:5.*": "OkHttp3Coroutines-5.x",
"com.squareup.okhttp3:okhttp-jvm:5.*": "OkHttp3Jvm-5.x",
"org.jetbrains.kotlin:kotlin-stdlib-common:2.0.*": "KotlinStdlibCommon-2.x",
"org.jetbrains.kotlin:kotlin-stdlib:2.0.*": "KotlinStdlib-2.x",
"org.jetbrains.kotlinx:atomicfu:0.*.*": "Atomicfu-0.x",
"org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.8.*": "KotlinxCoroutinesCoreJvm-1.8.x",
"org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.*": "KotlinxCoroutinesCore-1.8.x",
"org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.8.*": "KotlinxCoroutinesJdk8-1.8.x",

"com.squareup.okhttp3:okhttp-coroutines:5.*": "OkHttp3Coroutines-5x",
"com.squareup.okhttp3:okhttp:5.*": "OkHttp3-5.x",
"com.squareup.okio:okio-jvm:3.*": "OkioJvm-3.x",
"com.squareup.okio:okio:3.*": "Okio-3.x",
"io.opentelemetry:opentelemetry-api:1.*": "Maven-io-opentelemetry_opentelemetry-api-1.x",
"org.jetbrains.kotlin:kotlin-stdlib-common:1.9.*": "KotlinStdlibCommon-1.9.x",
"org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.*": "KotlinStdlibJdk8-1.9.x",
"org.jetbrains.kotlin:kotlin-stdlib:1.9.*": "KotlinStdlib-1.9.x",
"org.jetbrains.kotlinx:atomicfu-jvm:0.23.1": "AtomicfuJvm-0.23.1",
"org.jetbrains.kotlinx:atomicfu:0.23.1": "Atomicfu-0.23.1",
"org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.7.*": "KotlinxCoroutinesCoreJvm-1.7.x",
"org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.*": "KotlinxCoroutinesCore-1.7.x",
"org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.7.*": "KotlinxCoroutinesJdk8-1.7.x",
"org.slf4j:slf4j-api:2.*": "Maven-org-slf4j_slf4j-api-2.x",
"software.amazon.awssdk.crt:aws-crt:0.*": "Aws-crt-java-1.0.x",
"aws.sdk.kotlin.crt:aws-crt-kotlin:0.8.*": "AwsCrtKotlin-0.8.x"
Expand All @@ -39,34 +36,18 @@
"aws.smithy.kotlin:version-catalog"
],
"resolvesConflictDependencies": {
"com.squareup.okhttp3:okhttp-coroutines-jvm:5.*": [
"KotlinStdlibCommon-1.9.x",
"KotlinStdlib-1.9.x",
"KotlinxCoroutinesCoreJvm-1.7.x"
],
"com.squareup.okhttp3:okhttp-coroutines:5.*": [
"KotlinStdlibCommon-1.9.x",
"KotlinStdlib-1.9.x",
"KotlinxCoroutinesCoreJvm-1.7.x"
],
"com.squareup.okhttp3:okhttp-jvm:5.*": [
"KotlinStdlibCommon-1.9.x",
"KotlinStdlib-1.9.x"
"KotlinStdlibCommon-2.x",
"KotlinStdlib-2.x",
"KotlinxCoroutinesCoreJvm-1.8.x"
],
"com.squareup.okhttp3:okhttp:5.*": [
"KotlinStdlibCommon-1.9.x",
"KotlinStdlib-1.9.x"
"KotlinStdlibCommon-2.x",
"KotlinStdlib-2.x"
],
"com.squareup.okio:okio-jvm:3.*": [
"KotlinStdlibCommon-1.9.x",
"KotlinStdlibJdk8-1.9.x"
],
"org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.7.*": [
"KotlinStdlibCommon-1.9.x",
"KotlinStdlibJdk8-1.9.x"
],
"org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.7.*": [
"KotlinStdlibJdk8-1.9.x"
"KotlinStdlibCommon-2.x",
"KotlinStdlibJdk8-2.x"
]
}
}
Expand Down
6 changes: 6 additions & 0 deletions .changes/a44842e7-3418-48ce-b2a9-99718c72c43b.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"id": "a44842e7-3418-48ce-b2a9-99718c72c43b",
"type": "misc",
"description": "⚠️ **IMPORTANT**: Upgrade to Kotlin 2.0.0",
"requiresMinorVersionBump": true
}
3 changes: 2 additions & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ jobs:
- name: Test
shell: bash
run: |
echo "kotlinWarningsAsErrors=true" >> $GITHUB_WORKSPACE/local.properties
# FIXME K2. Re-enable warnings as errors after this warning is removed: https://youtrack.jetbrains.com/issue/KT-68532
# echo "kotlinWarningsAsErrors=true" >> $GITHUB_WORKSPACE/local.properties
Comment on lines -63 to +64
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: Without this suppression which error(s) are seen? Just errors related to @Suppress("INAPPLICABLE_JVM_NAME")?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah that's the only one. Since K2, they have started giving warnings for using this suppression, but the warning will be disabled again soon.

./gradlew apiCheck
./gradlew test jvmTest
- name: Save Test Reports
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ private fun getDefaultRuntimeVersion(): String {
// publishing info
const val RUNTIME_GROUP: String = "aws.smithy.kotlin"
val RUNTIME_VERSION: String = System.getProperty("smithy.kotlin.codegen.clientRuntimeVersion", getDefaultRuntimeVersion())
val KOTLIN_COMPILER_VERSION: String = System.getProperty("smithy.kotlin.codegen.kotlinCompilerVersion", "1.9.21")
val KOTLIN_COMPILER_VERSION: String = System.getProperty("smithy.kotlin.codegen.kotlinCompilerVersion", "2.0.0")

enum class SourceSet {
CommonMain,
Expand Down
12 changes: 5 additions & 7 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[versions]
kotlin-version = "1.9.23"
kotlin-version = "2.0.0"
dokka-version = "1.9.10"

aws-kotlin-repo-tools-version = "0.4.6"
aws-kotlin-repo-tools-version = "0.4.8"

# libs
coroutines-version = "1.7.3"
atomicfu-version = "0.23.1"
coroutines-version = "1.8.1"
atomicfu-version = "0.24.0"
okhttp-version = "5.0.0-alpha.14"
okio-version = "3.9.0"
otel-version = "1.32.0"
Expand All @@ -21,16 +21,14 @@ smithy-gradle-version = "0.9.0"
# testing
junit-version = "5.10.1"
kotest-version = "5.8.0"
kotlin-compile-testing-version = "1.5.0"
kotlin-compile-testing-version = "1.6.0"
kotlinx-benchmark-version = "0.4.9"
kotlinx-serialization-version = "1.6.0"
docker-java-version = "3.3.6"
ktor-version = "2.3.6"
kaml-version = "0.55.0"
jsoup-version = "1.16.2"



[libraries]
aws-kotlin-repo-tools-build-support = { module="aws.sdk.kotlin.gradle:build-support", version.ref = "aws-kotlin-repo-tools-version" }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ public expect class TelemetryContextElement(context: Context) : CoroutineContext
public companion object Key : CoroutineContext.Key<TelemetryContextElement>

public val context: Context
override val key: CoroutineContext.Key<*>
override fun <E : CoroutineContext.Element> get(key: CoroutineContext.Key<E>): E?
override fun <R> fold(initial: R, operation: (R, CoroutineContext.Element) -> R): R
override fun plus(context: CoroutineContext): CoroutineContext
override fun minusKey(key: CoroutineContext.Key<*>): CoroutineContext
}
Comment on lines 17 to 25
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: The K2 migration guide shows overriding abstract members with the expect keyword, which is not included here. Do you know what the difference is? Is expect an optional keyword for abstract members of expect classes or does it change the meaning/implementation somehow?


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ val startTestServers = task<LocalTestServers>("startTestServers") {

main = "aws.smithy.kotlin.runtime.http.test.util.TestServersKt"
val kotlinCompilation = kotlin.targets.getByName("jvm").compilations["test"]
classpath = (kotlinCompilation as org.jetbrains.kotlin.gradle.plugin.KotlinCompilationToRunnableFiles<*>).runtimeDependencyFiles
classpath = kotlinCompilation.runtimeDependencyFiles!!
sslConfigPath = File.createTempFile("ssl-", ".cfg").absolutePath
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@

package aws.smithy.kotlin.runtime.http.test.util

import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withTimeout
import kotlinx.coroutines.*
import kotlin.coroutines.CoroutineContext
import kotlin.time.Duration

Expand Down
39 changes: 39 additions & 0 deletions runtime/runtime-core/api/runtime-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,45 @@ public final class aws/smithy/kotlin/runtime/config/EnvironmentSettingKt {
public static synthetic fun resolve$default (Laws/smithy/kotlin/runtime/config/EnvironmentSetting;Laws/smithy/kotlin/runtime/util/PlatformEnvironProvider;ILjava/lang/Object;)Ljava/lang/Object;
}

public final class aws/smithy/kotlin/runtime/content/BigDecimal : java/lang/Number {
public fun <init> (Ljava/lang/String;)V
public final fun byteValue ()B
public final fun doubleValue ()D
public fun equals (Ljava/lang/Object;)Z
public final fun floatValue ()F
public final fun getValue ()Ljava/lang/String;
public final fun intValue ()I
public final fun longValue ()J
public final fun shortValue ()S
public fun toByte ()B
public fun toDouble ()D
public fun toFloat ()F
public fun toInt ()I
public fun toLong ()J
public final fun toPlainString ()Ljava/lang/String;
public fun toShort ()S
}

public final class aws/smithy/kotlin/runtime/content/BigInteger : java/lang/Number {
public fun <init> (Ljava/lang/String;)V
public final fun byteValue ()B
public final fun doubleValue ()D
public fun equals (Ljava/lang/Object;)Z
public final fun floatValue ()F
public final fun getValue ()Ljava/lang/String;
public fun hashCode ()I
public final fun intValue ()I
public final fun longValue ()J
public final fun shortValue ()S
public fun toByte ()B
public fun toDouble ()D
public fun toFloat ()F
public fun toInt ()I
public fun toLong ()J
public fun toShort ()S
public fun toString ()Ljava/lang/String;
}

public abstract class aws/smithy/kotlin/runtime/content/ByteStream {
public static final field Companion Laws/smithy/kotlin/runtime/content/ByteStream$Companion;
public fun getContentLength ()Ljava/lang/Long;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public interface MutableMultiMap<K, V> : MutableMap<K, MutableList<V>> {
* @param value The value to disassociate
* @return True if the given value was previously associated with the given key; otherwise, false.
*/
@Suppress("INAPPLICABLE_JVM_NAME")
@Suppress("INAPPLICABLE_JVM_NAME") // https://youtrack.jetbrains.com/issue/KT-68532
@JvmName("removeElement")
public fun remove(key: K, value: V): Boolean

Expand Down Expand Up @@ -169,7 +169,7 @@ internal class SimpleMutableMultiMap<K, V>(

override fun hashCode(): Int = delegate.hashCode()

@Suppress("INAPPLICABLE_JVM_NAME")
@Suppress("INAPPLICABLE_JVM_NAME") // https://youtrack.jetbrains.com/issue/KT-68532
@JvmName("removeElement")
override fun remove(key: K, value: V): Boolean = this[key]?.remove(value) ?: false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ internal class MutableMultiMapView<KSrc, KDest, VSrc, VDest>(
}
override fun remove(key: KDest): MutableList<VDest>? = src.remove(kDest2Src(key))?.let(vListSrc2Dest)

@Suppress("INAPPLICABLE_JVM_NAME")
@Suppress("INAPPLICABLE_JVM_NAME") // https://youtrack.jetbrains.com/issue/KT-68532
@JvmName("removeElement")
override fun remove(key: KDest, value: VDest): Boolean = src.remove(kDest2Src(key), vDest2Src(value))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@

package aws.smithy.kotlin.runtime.compression

import aws.smithy.kotlin.runtime.content.ByteStream

/**
* The gzip compression algorithm.
* Used to compress http requests.
*
* See: https://en.wikipedia.org/wiki/Gzip
*/
public expect class Gzip() : CompressionAlgorithm
public expect class Gzip() : CompressionAlgorithm {
override val id: String
override val contentEncoding: String
override fun compress(stream: ByteStream): ByteStream
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,12 @@
package aws.smithy.kotlin.runtime.content

public expect class BigDecimal(value: String) : Number {
override fun toByte(): Byte
override fun toDouble(): Double
override fun toFloat(): Float
override fun toShort(): Short
override fun toInt(): Int
override fun toLong(): Long
public fun toPlainString(): String
override fun equals(other: Any?): Boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,14 @@
*/
package aws.smithy.kotlin.runtime.content

public expect class BigInteger(value: String) : Number
public expect class BigInteger(value: String) : Number {
override fun toByte(): Byte
override fun toLong(): Long
override fun toShort(): Short
override fun toInt(): Int
override fun toFloat(): Float
override fun toDouble(): Double
override fun toString(): String
override fun hashCode(): Int
override fun equals(other: Any?): Boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@ public abstract class Crc32Base : HashFunction {
* directly to avoid doing the integer conversion yourself.
*/
@InternalApi
public expect class Crc32() : Crc32Base
public expect class Crc32() : Crc32Base {
override fun update(input: ByteArray, offset: Int, length: Int)
override fun digest(): ByteArray
override fun digestValue(): UInt
override fun reset()
override val blockSizeBytes: Int
override val digestSizeBytes: Int
}

/**
* Compute the CRC32 checksum of the given [ByteArray]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ public abstract class Md5Base : HashFunction {
* Implementation of RFC1321 MD5 digest
*/
@InternalApi
public expect class Md5() : Md5Base
public expect class Md5() : Md5Base {
override fun update(input: ByteArray, offset: Int, length: Int)
override fun digest(): ByteArray
override fun reset()
override val blockSizeBytes: Int
override val digestSizeBytes: Int
}

/**
* Compute the MD5 hash of the current [ByteArray]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ public abstract class Sha1Base : HashFunction {
* Implementation of SHA-1 (Secure Hash Algorithm 1) hash function. See: https://csrc.nist.gov/projects/hash-functions
*/
@InternalApi
public expect class Sha1() : Sha1Base
public expect class Sha1() : Sha1Base {
override fun update(input: ByteArray, offset: Int, length: Int)
override fun digest(): ByteArray
override fun reset()
override val blockSizeBytes: Int
override val digestSizeBytes: Int
}

/**
* Compute the SHA-1 hash of the current [ByteArray]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ public abstract class Sha256Base : HashFunction {

*/
@InternalApi
public expect class Sha256() : Sha256Base
public expect class Sha256() : Sha256Base {
override fun update(input: ByteArray, offset: Int, length: Int)
override fun digest(): ByteArray
override fun reset()
override val blockSizeBytes: Int
override val digestSizeBytes: Int
}

/**
* Compute the SHA-256 hash of the current [ByteArray]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,24 @@ package aws.smithy.kotlin.runtime.io
import aws.smithy.kotlin.runtime.io.internal.toOkio
import aws.smithy.kotlin.runtime.io.internal.toSdk

internal expect class BufferedSinkAdapter(sink: okio.BufferedSink) : SdkBufferedSink
internal expect class BufferedSinkAdapter(sink: okio.BufferedSink) : SdkBufferedSink {
override fun writeShortLe(x: Short)
override fun writeUtf8(string: String, start: Int, endExclusive: Int)
override val buffer: SdkBuffer
override fun writeShort(x: Short)
override fun writeLongLe(x: Long)
override fun emit()
override fun flush()
override fun close()
override fun write(source: SdkSource, byteCount: Long)
override fun write(source: SdkBuffer, byteCount: Long)
override fun writeAll(source: SdkSource): Long
override fun writeIntLe(x: Int)
override fun writeInt(x: Int)
override fun writeByte(x: Byte)
override fun writeLong(x: Long)
override fun write(source: ByteArray, offset: Int, limit: Int)
}

// base class that fills in most of the common implementation, platforms just need to implement the platform specific
// part of the interface
Expand Down
Loading
Loading