Skip to content

1318: Update to Kotlin 2.1.20 #1320

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

Merged
merged 1 commit into from
May 23, 2025
Merged
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
24 changes: 21 additions & 3 deletions .github/actions/gradle-task/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ inputs:
write-cache-key:
description: 'The unique identifier for the associated cache. Any other consumers or producers for this cache must use the same name.'
default: 'null'
failure-path-upload:
description: 'The relative path to a desired log for upload if the task fails.'
default: 'null'

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

- name: Upload heap dump
- name: Upload Any Logs
if: failure()
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4
with:
name: log-upload
path: ${{github.workspace}}/**/*.log

- name: Upload Any Heap Dumps
if: failure()
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4
with:
name: heap-dump
path: ${{github.workspace}}/**/*{.hprof,.log}
name: hprof-upload
path: ${{github.workspace}}/**/*.hprof

- name: Upload Any Specified Files
if: failure() && inputs.failure-path-upload != 'null'
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4
with:
name: specified-upload
path: ${{github.workspace}}/${{inputs.failure-path-upload}}

22 changes: 18 additions & 4 deletions .github/actions/gradle-tasks-with-emulator/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,23 @@ runs:
profile: Galaxy Nexus
script: ./gradlew ${{ inputs.test-task }}

- name: Upload results
if: ${{ always() }}
- name: Upload Any Logs
if: failure()
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4
with:
name: ${{ inputs.tests-name }}
path: ${{github.workspace}}/**/build/reports/androidTests/connected/**
name: log-upload
path: ${{github.workspace}}/**/*.log

- name: Upload Any Heap Dumps
if: failure()
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4
with:
name: hprof-upload
path: ${{github.workspace}}/**/*.hprof

- name: Upload Any Specified Files
if: failure() && inputs.failure-path-upload != 'null'
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4
with:
name: specified-upload
path: ${{github.workspace}}/${{inputs.failure-path-upload}}
6 changes: 3 additions & 3 deletions .github/workflows/kotlin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ jobs :

check :
name : Check
runs-on : ubuntu-latest
runs-on : macos-latest
needs : build-all
timeout-minutes : 20
steps :
Expand Down Expand Up @@ -329,8 +329,8 @@ jobs :

js-tests :
name : JS Tests
runs-on : ubuntu-latest
timeout-minutes : 20
runs-on : macos-latest
timeout-minutes : 30
steps :
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
Expand Down
1 change: 1 addition & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
registry=https://registry.yarnpkg.com
4 changes: 2 additions & 2 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ To build and install the current version to your local Maven repository (`~/.m2`

#### Configuration

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

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

You can verify the artifacts are available by visiting
https://s01.oss.sonatype.org/content/repositories/snapshots/com/squareup/workflow1/.
https://central.sonatype.org/content/repositories/snapshots/com/squareup/workflow1/.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import kotlinx.coroutines.flow.Flow
typealias IsLoading = Boolean

class MaybeLoadingGatekeeperWorkflow<T : Any>(
private val childWithLoading: Workflow<T, Any, OverviewDetailScreen<*>>,
private val childWithLoading: Workflow<T, *, OverviewDetailScreen<*>>,
private val childProps: T,
private val isLoading: Flow<Boolean>
) : StatefulWorkflow<Unit, IsLoading, Unit, MayBeLoadingScreen>() {
Expand Down
2 changes: 1 addition & 1 deletion build-logic/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
// Hardcoded as this is upstream of the version catalog. Keep this in sync with that.
kotlin("jvm") version "1.9.24" apply false
kotlin("jvm") version "2.1.21" apply false
}

dependencyResolutionManagement {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ class KotlinAndroidConventionPlugin : Plugin<Project> {
components.onVariants(
selector = components.selector().withBuildType("debug")
) { variant ->
val nameCaps = variant.name.capitalized()
val nameCaps = variant.name
.replaceFirstChar { if (it.isLowerCase()) it.titlecase() else it.toString() }
val testTask = "connected${nameCaps}AndroidTest"
target.tasks.register("prepare${nameCaps}AndroidTestArtifacts") { task ->
task.description =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ import com.squareup.workflow1.buildsrc.internal.javaTargetInt
import com.squareup.workflow1.buildsrc.internal.kotlin
import org.gradle.api.Project
import org.gradle.api.tasks.compile.JavaCompile
import org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode.Strict
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile

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

tasks.withType(KotlinCompile::class.java).configureEach { kotlinCompile ->
kotlinCompile.kotlinOptions {
jvmTarget = [email protected]
kotlinCompile.apply {
if (!(path.startsWith(":samples") || path.startsWith(":benchmarks") ||
name.contains("test", ignoreCase = true))
) {
explicitApiMode.set(Strict)
}
}
kotlinCompile.compilerOptions {
jvmTarget.set(JvmTarget.fromTarget([email protected]))

// Allow warnings when running from IDE, makes it easier to experiment.
if (!isRunningFromIde) {
allWarningsAsErrors = true
allWarningsAsErrors.set(true)
}

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

// Make sure our module names don't conflict with those from pre-workflow1
// releases, so that old and new META-INF/ entries don't stomp each other.
// (This is only an issue for apps that are still migrating from workflow to
// workflow1, and so need to import two versions of the library.)
// https://blog.jetbrains.com/kotlin/2015/09/kotlin-m13-is-out/
moduleName = "wf1-${project.name}"
}

maybeEnableExplicitApi(kotlinCompile)
}
}

private fun Project.maybeEnableExplicitApi(compileTask: KotlinCompile) {
when {
path.startsWith(":samples") -> return
path.startsWith(":benchmarks") -> return
compileTask.name.contains("test", ignoreCase = true) -> return
else -> compileTask.kotlinOptions {
// TODO this should be moved to `kotlin { explicitApi() }` once that's working for android
// projects, see https://youtrack.jetbrains.com/issue/KT-37652.
freeCompilerArgs += "-Xexplicit-api=strict"
moduleName.set("wf1-${project.name}")
}
}
}
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ plugins {
id("artifacts-check")
id("dependency-guard")
alias(libs.plugins.ktlint)
alias(libs.plugins.compose.compiler) apply false
}

shardConnectedCheckTasks(project)
Expand Down
Loading
Loading