Skip to content

Commit 8a93381

Browse files
1318: Update to Kotlin 2.1.20
Update Gradle, AGP, Compose (now bundled with Kotlin). Update code and build files as necessary.
1 parent c8e0b29 commit 8a93381

File tree

65 files changed

+765
-689
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+765
-689
lines changed

.github/actions/gradle-task/action.yml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ inputs:
2020
write-cache-key:
2121
description: 'The unique identifier for the associated cache. Any other consumers or producers for this cache must use the same name.'
2222
default: 'null'
23+
failure-path-upload:
24+
description: 'The relative path to a desired log for upload if the task fails.'
25+
default: 'null'
2326

2427
runs:
2528
using: 'composite'
@@ -128,9 +131,24 @@ runs:
128131
./**/.gradle
129132
key: ${{runner.os}}-${{inputs.write-cache-key}}-${{hashFiles('**/libs.versions.toml')}}-${{hashFiles('**/gradle.properties')}}-${{hashFiles('**/*.gradle.kts')}}-${{hashFiles('**/src/**/*.kt')}}
130133

131-
- name: Upload heap dump
134+
- name: Upload Any Logs
135+
if: failure()
136+
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4
137+
with:
138+
name: log-upload
139+
path: ${{github.workspace}}/**/*.log
140+
141+
- name: Upload Any Heap Dumps
132142
if: failure()
133143
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4
134144
with:
135-
name: heap-dump
136-
path: ${{github.workspace}}/**/*{.hprof,.log}
145+
name: hprof-upload
146+
path: ${{github.workspace}}/**/*.hprof
147+
148+
- name: Upload Any Specified Files
149+
if: failure() && inputs.failure-path-upload != 'null'
150+
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4
151+
with:
152+
name: specified-upload
153+
path: ${{github.workspace}}/${{inputs.failure-path-upload}}
154+

.github/actions/gradle-tasks-with-emulator/action.yml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,23 @@ runs:
103103
profile: Galaxy Nexus
104104
script: ./gradlew ${{ inputs.test-task }}
105105

106-
- name: Upload results
107-
if: ${{ always() }}
106+
- name: Upload Any Logs
107+
if: failure()
108108
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4
109109
with:
110-
name: ${{ inputs.tests-name }}
111-
path: ${{github.workspace}}/**/build/reports/androidTests/connected/**
110+
name: log-upload
111+
path: ${{github.workspace}}/**/*.log
112+
113+
- name: Upload Any Heap Dumps
114+
if: failure()
115+
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4
116+
with:
117+
name: hprof-upload
118+
path: ${{github.workspace}}/**/*.hprof
119+
120+
- name: Upload Any Specified Files
121+
if: failure() && inputs.failure-path-upload != 'null'
122+
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4
123+
with:
124+
name: specified-upload
125+
path: ${{github.workspace}}/${{inputs.failure-path-upload}}

.github/workflows/kotlin.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ jobs :
140140

141141
check :
142142
name : Check
143-
runs-on : ubuntu-latest
143+
runs-on : macos-latest
144144
needs : build-all
145145
timeout-minutes : 20
146146
steps :
@@ -329,8 +329,8 @@ jobs :
329329

330330
js-tests :
331331
name : JS Tests
332-
runs-on : ubuntu-latest
333-
timeout-minutes : 20
332+
runs-on : macos-latest
333+
timeout-minutes : 30
334334
steps :
335335
- name: Checkout
336336
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

.yarnrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
registry=https://registry.yarnpkg.com

RELEASING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ To build and install the current version to your local Maven repository (`~/.m2`
130130

131131
#### Configuration
132132

133-
In order to deploy artifacts to `s01.oss.sonatype.org`, you'll need to provide
133+
In order to deploy artifacts to `central.sonatype.org`, you'll need to provide
134134
your credentials via these two properties in your private Gradle properties
135135
file(`~/.gradle/gradle.properties`).
136136

@@ -166,4 +166,4 @@ snapshot artifacts to Sonatype just like you would for a production release:
166166
```
167167

168168
You can verify the artifacts are available by visiting
169-
https://s01.oss.sonatype.org/content/repositories/snapshots/com/squareup/workflow1/.
169+
https://central.sonatype.org/content/repositories/snapshots/com/squareup/workflow1/.

benchmarks/performance-poetry/complex-poetry/src/main/java/com/squareup/benchmarks/performance/complex/poetry/MaybeLoadingGatekeeperWorkflow.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import kotlinx.coroutines.flow.Flow
1515
typealias IsLoading = Boolean
1616

1717
class MaybeLoadingGatekeeperWorkflow<T : Any>(
18-
private val childWithLoading: Workflow<T, Any, OverviewDetailScreen<*>>,
18+
private val childWithLoading: Workflow<T, *, OverviewDetailScreen<*>>,
1919
private val childProps: T,
2020
private val isLoading: Flow<Boolean>
2121
) : StatefulWorkflow<Unit, IsLoading, Unit, MayBeLoadingScreen>() {

build-logic/settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
plugins {
22
// Hardcoded as this is upstream of the version catalog. Keep this in sync with that.
3-
kotlin("jvm") version "1.9.24" apply false
3+
kotlin("jvm") version "2.1.21" apply false
44
}
55

66
dependencyResolutionManagement {

build-logic/src/main/java/com/squareup/workflow1/buildsrc/KotlinAndroidConventionPlugin.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ class KotlinAndroidConventionPlugin : Plugin<Project> {
1616
components.onVariants(
1717
selector = components.selector().withBuildType("debug")
1818
) { variant ->
19-
val nameCaps = variant.name.capitalized()
19+
val nameCaps = variant.name
20+
.replaceFirstChar { if (it.isLowerCase()) it.titlecase() else it.toString() }
2021
val testTask = "connected${nameCaps}AndroidTest"
2122
target.tasks.register("prepare${nameCaps}AndroidTestArtifacts") { task ->
2223
task.description =

build-logic/src/main/java/com/squareup/workflow1/buildsrc/KotlinCommonSettings.kt

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ import com.squareup.workflow1.buildsrc.internal.javaTargetInt
1010
import com.squareup.workflow1.buildsrc.internal.kotlin
1111
import org.gradle.api.Project
1212
import org.gradle.api.tasks.compile.JavaCompile
13+
import org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode.Strict
14+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
1315
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
1416
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
17+
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
1518

1619
fun Project.kotlinCommonSettings(bomConfigurationName: String) {
1720
pluginManager.apply(libsCatalog.pluginId("ktlint"))
@@ -28,39 +31,31 @@ fun Project.kotlinCommonSettings(bomConfigurationName: String) {
2831
}
2932

3033
tasks.withType(KotlinCompile::class.java).configureEach { kotlinCompile ->
31-
kotlinCompile.kotlinOptions {
32-
jvmTarget = this@kotlinCommonSettings.javaTarget
34+
kotlinCompile.apply {
35+
if (!(path.startsWith(":samples") || path.startsWith(":benchmarks") ||
36+
name.contains("test", ignoreCase = true))
37+
) {
38+
explicitApiMode.set(Strict)
39+
}
40+
}
41+
kotlinCompile.compilerOptions {
42+
jvmTarget.set(JvmTarget.fromTarget(this@kotlinCommonSettings.javaTarget))
3343

3444
// Allow warnings when running from IDE, makes it easier to experiment.
3545
if (!isRunningFromIde) {
36-
allWarningsAsErrors = true
46+
allWarningsAsErrors.set(true)
3747
}
3848

3949
// Don't panic, all this does is allow us to use the @OptIn meta-annotation.
4050
// to define our own experiments.
41-
freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn"
51+
freeCompilerArgs.add("-opt-in=kotlin.RequiresOptIn")
4252

4353
// Make sure our module names don't conflict with those from pre-workflow1
4454
// releases, so that old and new META-INF/ entries don't stomp each other.
4555
// (This is only an issue for apps that are still migrating from workflow to
4656
// workflow1, and so need to import two versions of the library.)
4757
// https://blog.jetbrains.com/kotlin/2015/09/kotlin-m13-is-out/
48-
moduleName = "wf1-${project.name}"
49-
}
50-
51-
maybeEnableExplicitApi(kotlinCompile)
52-
}
53-
}
54-
55-
private fun Project.maybeEnableExplicitApi(compileTask: KotlinCompile) {
56-
when {
57-
path.startsWith(":samples") -> return
58-
path.startsWith(":benchmarks") -> return
59-
compileTask.name.contains("test", ignoreCase = true) -> return
60-
else -> compileTask.kotlinOptions {
61-
// TODO this should be moved to `kotlin { explicitApi() }` once that's working for android
62-
// projects, see https://youtrack.jetbrains.com/issue/KT-37652.
63-
freeCompilerArgs += "-Xexplicit-api=strict"
58+
moduleName.set("wf1-${project.name}")
6459
}
6560
}
6661
}

build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ plugins {
2727
id("artifacts-check")
2828
id("dependency-guard")
2929
alias(libs.plugins.ktlint)
30+
alias(libs.plugins.compose.compiler) apply false
3031
}
3132

3233
shardConnectedCheckTasks(project)

0 commit comments

Comments
 (0)