Skip to content

Commit 2dcec64

Browse files
authored
feat(all): Update Kotlin language version to 2.2.0 (#256)
1 parent d4e5edb commit 2dcec64

File tree

26 files changed

+354
-460
lines changed

26 files changed

+354
-460
lines changed

authenticator/api/authenticator.api

Lines changed: 90 additions & 150 deletions
Large diffs are not rendered by default.

authenticator/src/main/java/com/amplifyframework/ui/authenticator/util/AnnotatedStringResource.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import androidx.compose.ui.text.font.FontWeight
3333
import androidx.compose.ui.text.style.TextDecoration
3434
import androidx.core.text.HtmlCompat
3535
import androidx.core.text.HtmlCompat.FROM_HTML_MODE_COMPACT
36+
import androidx.core.text.toHtml
3637

3738
/**
3839
* Reads an HTML string from resources and turns it into an [AnnotatedString]
@@ -63,7 +64,7 @@ private fun Context.getText(
6364
vararg formatArgs: Any
6465
): CharSequence {
6566
val resource = SpannedString(getText(id))
66-
val html = HtmlCompat.toHtml(resource, HtmlCompat.TO_HTML_PARAGRAPH_LINES_CONSECUTIVE)
67+
val html = resource.toHtml()
6768
val string = String.format(html, *formatArgs)
6869
return HtmlCompat.fromHtml(string, FROM_HTML_MODE_COMPACT)
6970
}

build-logic/plugins/build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ dependencies {
4545

4646
gradlePlugin {
4747
plugins {
48+
register("androidApplication") {
49+
id = "amplify.android.application"
50+
implementationClass = "AndroidApplicationConventionPlugin"
51+
}
4852
register("androidLibrary") {
4953
id = "amplify.android.library"
5054
implementationClass = "AndroidLibraryConventionPlugin"
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
import com.amplify.ui.configureAndroid
17+
import com.android.build.api.dsl.ApplicationExtension
18+
import org.gradle.api.Plugin
19+
import org.gradle.api.Project
20+
import org.gradle.api.tasks.compile.JavaCompile
21+
import org.gradle.api.tasks.testing.Test
22+
import org.gradle.kotlin.dsl.configure
23+
import org.gradle.kotlin.dsl.provideDelegate
24+
import org.gradle.kotlin.dsl.withType
25+
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
26+
27+
/**
28+
* This convention plugin configures an Android library module
29+
*/
30+
class AndroidApplicationConventionPlugin : Plugin<Project> {
31+
override fun apply(target: Project) {
32+
with(target.pluginManager) {
33+
apply("com.android.application")
34+
apply("org.jetbrains.kotlin.plugin.compose")
35+
apply("org.jetbrains.kotlin.android")
36+
}
37+
38+
with(target) {
39+
extensions.configure<ApplicationExtension> {
40+
target.configureAndroid(this)
41+
defaultConfig {
42+
targetSdk = 34
43+
versionCode = 1
44+
versionName = "1"
45+
}
46+
compileOptions {
47+
isCoreLibraryDesugaringEnabled = true
48+
}
49+
}
50+
51+
tasks.withType<JavaCompile>().configureEach {
52+
options.compilerArgs.apply {
53+
add("-Xlint:all")
54+
add("-Werror")
55+
}
56+
}
57+
58+
tasks.withType<Test>().configureEach {
59+
minHeapSize = "128m"
60+
maxHeapSize = "4g"
61+
}
62+
63+
configure<KotlinProjectExtension> {
64+
jvmToolchain(17)
65+
}
66+
}
67+
}
68+
}

build-logic/plugins/src/main/kotlin/AndroidLibraryConventionPlugin.kt

Lines changed: 6 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,16 @@
1313
* permissions and limitations under the License.
1414
*/
1515

16+
import com.amplify.ui.configureAndroid
1617
import com.android.build.api.dsl.LibraryExtension
17-
import org.gradle.api.JavaVersion
1818
import org.gradle.api.Plugin
1919
import org.gradle.api.Project
2020
import org.gradle.api.tasks.compile.JavaCompile
2121
import org.gradle.api.tasks.testing.Test
2222
import org.gradle.kotlin.dsl.configure
23-
import org.gradle.kotlin.dsl.extra
2423
import org.gradle.kotlin.dsl.provideDelegate
2524
import org.gradle.kotlin.dsl.withType
2625
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
27-
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2826

2927
/**
3028
* This convention plugin configures an Android library module
@@ -34,6 +32,7 @@ class AndroidLibraryConventionPlugin : Plugin<Project> {
3432
override fun apply(target: Project) {
3533
with(target.pluginManager) {
3634
apply("com.android.library")
35+
apply("org.jetbrains.kotlin.plugin.compose")
3736
apply("org.jetbrains.kotlin.android")
3837
apply("amplify.android.ktlint")
3938
}
@@ -43,7 +42,10 @@ class AndroidLibraryConventionPlugin : Plugin<Project> {
4342
with(target) {
4443
group = POM_GROUP
4544
extensions.configure<LibraryExtension> {
46-
configureAndroid(this)
45+
target.configureAndroid(this)
46+
defaultConfig {
47+
consumerProguardFiles += rootProject.file("configuration/consumer-rules.pro")
48+
}
4749
}
4850

4951
tasks.withType<JavaCompile>().configureEach {
@@ -63,61 +65,4 @@ class AndroidLibraryConventionPlugin : Plugin<Project> {
6365
}
6466
}
6567
}
66-
67-
private fun Project.configureAndroid(extension: LibraryExtension) {
68-
val sdkVersionName = findProperty("VERSION_NAME") ?: rootProject.findProperty("VERSION_NAME")
69-
70-
if (hasProperty("signingKeyId")) {
71-
println("Getting signing info from protected source.")
72-
extra["signing.keyId"] = findProperty("signingKeyId")
73-
extra["signing.password"] = findProperty("signingPassword")
74-
extra["signing.inMemoryKey"] = findProperty("signingInMemoryKey")
75-
}
76-
77-
extension.apply {
78-
compileSdk = 35
79-
80-
buildFeatures {
81-
buildConfig = true
82-
}
83-
84-
defaultConfig {
85-
minSdk = 24
86-
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
87-
testInstrumentationRunnerArguments += "clearPackageData" to "true"
88-
consumerProguardFiles += rootProject.file("configuration/consumer-rules.pro")
89-
90-
testOptions {
91-
animationsDisabled = true
92-
unitTests {
93-
isIncludeAndroidResources = true
94-
}
95-
}
96-
97-
buildConfigField("String", "VERSION_NAME", "\"$sdkVersionName\"")
98-
}
99-
100-
lint {
101-
warningsAsErrors = true
102-
abortOnError = true
103-
enable += listOf("UnusedResources")
104-
disable += listOf("GradleDependency", "NewerVersionAvailable", "AndroidGradlePluginVersion")
105-
}
106-
107-
// Needed when running integration tests. The oauth2 library uses relies on two
108-
// dependencies (Apache's httpcore and httpclient), both of which include
109-
// META-INF/DEPENDENCIES. Tried a couple other options to no avail.
110-
packaging {
111-
resources.excludes += setOf("META-INF/DEPENDENCIES", "META-INF/LICENSE*")
112-
}
113-
114-
buildFeatures {
115-
compose = true
116-
}
117-
118-
composeOptions {
119-
kotlinCompilerExtensionVersion = "1.5.3"
120-
}
121-
}
122-
}
12368
}

build-logic/plugins/src/main/kotlin/ComponentConventionPlugin.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ class ComponentConventionPlugin : Plugin<Project> {
3737
pluginManager.apply("amplify.android.screenshots")
3838

3939
tasks.withType<KotlinCompile>().configureEach {
40-
kotlinOptions {
41-
freeCompilerArgs = freeCompilerArgs + amplifyInternalMarkers.map { "-opt-in=$it" }
40+
compilerOptions {
41+
freeCompilerArgs.addAll(amplifyInternalMarkers.map { "-opt-in=$it" })
4242
}
4343
}
4444
}

build-logic/plugins/src/main/kotlin/PublishingConventionPlugin.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import org.gradle.api.Project
44
import org.gradle.api.publish.PublishingExtension
55
import org.gradle.api.publish.maven.MavenPublication
66
import org.gradle.kotlin.dsl.configure
7+
import org.gradle.kotlin.dsl.extra
78
import org.gradle.kotlin.dsl.get
89
import org.gradle.kotlin.dsl.provideDelegate
910
import org.gradle.plugins.signing.SigningExtension
@@ -128,6 +129,12 @@ class PublishingConventionPlugin : Plugin<Project> {
128129
}
129130

130131
configure<SigningExtension> {
132+
if (hasProperty("signingKeyId")) {
133+
println("Getting signing info from protected source.")
134+
extra["signing.keyId"] = findProperty("signingKeyId")
135+
extra["signing.password"] = findProperty("signingPassword")
136+
extra["signing.inMemoryKey"] = findProperty("signingInMemoryKey")
137+
}
131138
isRequired = isReleaseBuild && gradle.taskGraph.hasTask("publish")
132139
if (hasProperty("signing.inMemoryKey")) {
133140
val signingKey = findProperty("signing.inMemoryKey").toString().replace("\\n", "\n")
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
package com.amplify.ui
16+
17+
import com.android.build.api.dsl.CommonExtension
18+
import org.gradle.api.Project
19+
20+
internal fun Project.configureAndroid(extension: CommonExtension<*, *, *, *, *, *>) {
21+
val sdkVersionName = findProperty("VERSION_NAME") ?: rootProject.findProperty("VERSION_NAME")
22+
23+
extension.apply {
24+
compileSdk = 35
25+
26+
buildFeatures {
27+
buildConfig = true
28+
}
29+
30+
defaultConfig {
31+
minSdk = 24
32+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
33+
testInstrumentationRunnerArguments += "clearPackageData" to "true"
34+
35+
testOptions {
36+
animationsDisabled = true
37+
unitTests {
38+
isIncludeAndroidResources = true
39+
}
40+
}
41+
42+
buildConfigField("String", "VERSION_NAME", "\"$sdkVersionName\"")
43+
}
44+
45+
lint {
46+
warningsAsErrors = true
47+
abortOnError = true
48+
enable += listOf("UnusedResources")
49+
disable += listOf("GradleDependency", "NewerVersionAvailable", "AndroidGradlePluginVersion")
50+
}
51+
52+
// Needed when running integration tests. The oauth2 library uses relies on two
53+
// dependencies (Apache's httpcore and httpclient), both of which include
54+
// META-INF/DEPENDENCIES. Tried a couple other options to no avail.
55+
packaging {
56+
resources.excludes += setOf("META-INF/DEPENDENCIES", "META-INF/LICENSE*")
57+
}
58+
59+
buildFeatures {
60+
compose = true
61+
}
62+
63+
composeOptions {
64+
kotlinCompilerExtensionVersion = "1.5.3"
65+
}
66+
}
67+
}

build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ plugins {
1111
alias(libs.plugins.android.application) apply false
1212
alias(libs.plugins.android.library) apply false
1313
alias(libs.plugins.binary.compatibility) apply false
14+
alias(libs.plugins.compose.compiler) apply false
1415
alias(libs.plugins.kotlin.android) apply false
1516
alias(libs.plugins.kotlin.serialization) apply false
1617
alias(libs.plugins.kover)
@@ -20,7 +21,7 @@ plugins {
2021
}
2122

2223
tasks.register<Delete>("clean").configure {
23-
delete(rootProject.buildDir)
24+
delete(rootProject.layout.buildDirectory)
2425
}
2526

2627
kover {

gradle/libs.versions.toml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
[versions]
22
accompanist = "0.28.0"
3-
agp = "8.7.2"
4-
amplify = "2.29.0"
3+
agp = "8.11.1"
4+
amplify = "2.29.2"
55
appcompat = "1.6.1"
66
androidx-core = "1.9.0"
77
androidx-junit = "1.1.4"
88
androidx-activity = "1.6.1"
99
androidx-navigation = "2.5.3"
10-
binary-compatibility = "0.14.0"
10+
binary-compatibility = "0.18.1"
1111
cameraX = "1.4.2"
1212
compose-bom = "2025.06.01"
1313
coroutines = "1.7.3"
14-
desugar = "1.2.0"
14+
desugar = "2.1.5"
1515
futures = "1.1.0"
1616
junit = "4.13.2"
1717
kotest = "5.7.1"
18-
kotlin = "1.9.10"
18+
kotlin = "2.2.0"
1919
kover = "0.9.1"
2020
ktlint = "11.0.0"
2121
licensee = "1.7.0"
@@ -113,6 +113,7 @@ test = [
113113
android-application = { id = "com.android.application", version.ref = "agp" }
114114
android-library = { id = "com.android.library", version.ref = "agp" }
115115
binary-compatibility = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "binary-compatibility" }
116+
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
116117
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
117118
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
118119
kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }

0 commit comments

Comments
 (0)