Skip to content

Move workflow-runtime-android into android source set in workflow-runtime module. #1370

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
Jul 21, 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
18 changes: 9 additions & 9 deletions artifacts.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@
"javaVersion": 8,
"publicationName": "kotlinMultiplatform"
},
{
"gradlePath": ":workflow-runtime",
"group": "com.squareup.workflow1",
"artifactId": "workflow-runtime-android",
"description": "Workflow Runtime",
"packaging": "aar",
"javaVersion": 8,
"publicationName": "android"
},
{
"gradlePath": ":workflow-runtime",
"group": "com.squareup.workflow1",
Expand Down Expand Up @@ -125,15 +134,6 @@
"javaVersion": 8,
"publicationName": "kotlinMultiplatform"
},
{
"gradlePath": ":workflow-runtime-android",
"group": "com.squareup.workflow1",
"artifactId": "workflow-runtime-android",
"description": "Workflow Runtime Android",
"packaging": "aar",
"javaVersion": 8,
"publicationName": "maven"
},
{
"gradlePath": ":workflow-rx2",
"group": "com.squareup.workflow1",
Expand Down
1 change: 0 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ include(
":workflow-config:config-jvm",
":workflow-core",
":workflow-runtime",
":workflow-runtime-android",
":workflow-rx2",
":workflow-testing",
":workflow-tracing",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,66 @@
androidx.activity:activity-ktx:1.7.0
androidx.activity:activity:1.7.0
androidx.annotation:annotation-experimental:1.4.1
androidx.annotation:annotation-jvm:1.8.1
androidx.annotation:annotation:1.8.1
androidx.arch.core:core-common:2.2.0
androidx.arch.core:core-runtime:2.2.0
androidx.autofill:autofill:1.0.0
androidx.collection:collection-jvm:1.4.4
androidx.collection:collection-ktx:1.4.4
androidx.collection:collection:1.4.4
androidx.compose.runtime:runtime-android:1.7.2
androidx.compose.runtime:runtime-saveable-android:1.7.2
androidx.compose.runtime:runtime-saveable:1.7.2
androidx.compose.runtime:runtime:1.7.2
androidx.compose.ui:ui-android:1.7.2
androidx.compose.ui:ui-geometry-android:1.7.2
androidx.compose.ui:ui-geometry:1.7.2
androidx.compose.ui:ui-graphics-android:1.7.2
androidx.compose.ui:ui-graphics:1.7.2
androidx.compose.ui:ui-text-android:1.7.2
androidx.compose.ui:ui-text:1.7.2
androidx.compose.ui:ui-unit-android:1.7.2
androidx.compose.ui:ui-unit:1.7.2
androidx.compose.ui:ui-util-android:1.7.2
androidx.compose.ui:ui-util:1.7.2
androidx.compose:compose-bom:2024.09.02
androidx.concurrent:concurrent-futures:1.1.0
androidx.core:core-ktx:1.12.0
androidx.core:core:1.12.0
androidx.customview:customview-poolingcontainer:1.0.0
androidx.emoji2:emoji2:1.2.0
androidx.graphics:graphics-path:1.0.1
androidx.interpolator:interpolator:1.0.0
androidx.lifecycle:lifecycle-common-jvm:2.8.7
androidx.lifecycle:lifecycle-common:2.8.7
androidx.lifecycle:lifecycle-livedata-core:2.8.7
androidx.lifecycle:lifecycle-process:2.8.7
androidx.lifecycle:lifecycle-runtime-android:2.8.7
androidx.lifecycle:lifecycle-runtime-compose-android:2.8.7
androidx.lifecycle:lifecycle-runtime-compose:2.8.7
androidx.lifecycle:lifecycle-runtime-ktx-android:2.8.7
androidx.lifecycle:lifecycle-runtime-ktx:2.8.7
androidx.lifecycle:lifecycle-runtime:2.8.7
androidx.lifecycle:lifecycle-viewmodel-android:2.8.7
androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.7
androidx.lifecycle:lifecycle-viewmodel-savedstate:2.8.7
androidx.lifecycle:lifecycle-viewmodel:2.8.7
androidx.profileinstaller:profileinstaller:1.3.1
androidx.savedstate:savedstate-ktx:1.2.1
androidx.savedstate:savedstate:1.2.1
androidx.startup:startup-runtime:1.1.1
androidx.tracing:tracing:1.0.0
androidx.versionedparcelable:versionedparcelable:1.1.1
com.google.guava:listenablefuture:1.0
com.squareup.okio:okio-jvm:3.3.0
com.squareup.okio:okio:3.3.0
org.jetbrains.kotlin:kotlin-bom:2.0.21
org.jetbrains.kotlin:kotlin-stdlib-common:2.0.21
org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.0.21
org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.0.21
org.jetbrains.kotlin:kotlin-stdlib:2.0.21
org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3
org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.7.3
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.7.3
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3
Expand Down
11 changes: 0 additions & 11 deletions workflow-runtime-android/README.md

This file was deleted.

10 changes: 0 additions & 10 deletions workflow-runtime-android/api/workflow-runtime-android.api

This file was deleted.

35 changes: 0 additions & 35 deletions workflow-runtime-android/build.gradle.kts

This file was deleted.

3 changes: 0 additions & 3 deletions workflow-runtime-android/gradle.properties

This file was deleted.

10 changes: 5 additions & 5 deletions workflow-runtime/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ This module contains the core APIs and logic for running workflows.
## Kotlin Multiplatform

This module is a Kotlin Multiplatform module. The targets currently included for build and test
are `jvm`, `ios`, and `iosSimulatorSimulatorArm64`. If you are having issues with the tests,
ensure you have the correct version of XCode installed and can launch a simulator as it's specified
in the gradle build file (Currently iPhone 14).
are `jvm`, `android`, `ios`, and `iosSimulatorSimulatorArm64`. If you are having issues with the
tests, ensure you have the correct version of XCode installed and can launch a simulator as it's
specified in the gradle build file (Currently iPhone 14).

You can also choose to specify your targets for build and test with the property `workflow.targets`
as either `kmp`, `jvm`, `ios`, `js`. The default is `kmp` (all the targets). Set this in your
global `~/.gradle/gradle.properties` or specify the property in your gradle command, e.g.:
as either `kmp`, `jvm`, `android`, `ios`, `js`. The default is `kmp` (all the targets). Set this in
your global `~/.gradle/gradle.properties` or specify the property in your gradle command, e.g.:

```bash
./gradlew build -Pworkflow.targets=jvm
Expand Down
80 changes: 71 additions & 9 deletions workflow-runtime/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,32 +1,94 @@
import com.android.build.api.dsl.androidLibrary
import com.squareup.workflow1.buildsrc.iosWithSimulatorArm64

plugins {
id("kotlin-multiplatform")
id("com.android.kotlin.multiplatform.library")
id("published")
id("app.cash.burst")
}

kotlin {
// Needed for expect class Lock, which is not public API, so this doesn't add any binary compat
// risk.
compilerOptions.freeCompilerArgs.add("-Xexpect-actual-classes")

val targets = project.findProperty("workflow.targets") ?: "kmp"
if (targets == "kmp" || targets == "ios") {
iosWithSimulatorArm64()
}
if (targets == "kmp" || targets == "jvm") {
jvm {}
}
if (targets == "kmp" || targets == "android") {
androidLibrary {
namespace = "com.squareup.workflow1.android"
testNamespace = "$namespace.test"

compileSdk = libs.versions.compileSdk.get().toInt()
minSdk = libs.versions.minSdk.get().toInt()

withDeviceTestBuilder {
sourceSetTreeName = "test"
}.configure {
instrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

// Disable transition and rotation animations.
animationsDisabled = true
}
}
}
if (targets == "kmp" || targets == "js") {
js(IR) { browser() }
}

// Needed for expect class Lock, which is not public API, so this doesn't add any binary compat
// risk.
compilerOptions.freeCompilerArgs.add("-Xexpect-actual-classes")
}
sourceSets {
commonMain {
dependencies {
api(project(":workflow-core"))
api(libs.kotlinx.coroutines.core)
}
}

commonTest {
dependencies {
implementation(libs.kotlinx.coroutines.test.common)
implementation(libs.kotlin.test.core)
}
}

androidMain {
dependencies {
// Add Android-specific dependencies here. Note that this source set depends on
// commonMain by default and will correctly pull the Android artifacts of any KMP
// dependencies declared in commonMain.
val composeBom = project.dependencies.platform(libs.androidx.compose.bom)

dependencies {
commonMainApi(project(":workflow-core"))
commonMainApi(libs.kotlinx.coroutines.core)
api(libs.androidx.compose.ui.android)
api(libs.androidx.lifecycle.viewmodel.savedstate)

commonTestImplementation(libs.kotlinx.coroutines.test.common)
commonTestImplementation(libs.kotlin.test.core)
implementation(composeBom)
}
}

getByName("androidDeviceTest") {
dependencies {
implementation(project(":workflow-ui:internal-testing-android"))

implementation(libs.androidx.test.espresso.core)
implementation(libs.androidx.test.junit)
implementation(libs.squareup.leakcanary.instrumentation)

implementation(libs.androidx.activity.ktx)
implementation(libs.androidx.lifecycle.viewmodel.ktx)
implementation(libs.androidx.test.core)
implementation(libs.androidx.test.truth)
implementation(libs.kotlin.test.core)
implementation(libs.kotlin.test.jdk)
implementation(libs.kotlinx.coroutines.android)
implementation(libs.kotlinx.coroutines.test)
implementation(libs.squareup.papa)
}
}
}
}
10 changes: 10 additions & 0 deletions workflow-runtime/src/androidMain/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Android vs JVM targets

The default KMP
["hierarchy template"](https://www.jetbrains.com/help/kotlin-multiplatform-dev/multiplatform-hierarchy.html#see-the-full-hierarchy-template)
configures `androidMain` and `jvmMain` to be entirely separate targets, even though Android *can*
be made to be a child of JVM. Changing this requires completely wiring up all targets ourselves
though, so for now we've left them separate to simplify gradle config. If there ends up being too
much code duplication, we can either make `androidMain` a child of `jvmMain`, or introduce a new
shared target that includes both of them. Compose, for example, uses a structure where `jvm` is the
shared parent of both `android` and `desktop`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.squareup.workflow1.internal

internal actual typealias Lock = Any

internal actual inline fun <R> Lock.withLock(block: () -> R): R = synchronized(this, block)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.squareup.workflow1.internal

actual fun <T : Throwable> T.withKey(stackTraceKey: Any): T = apply {
val realTop = stackTrace[0]
val fakeTop = StackTraceElement(
// Real class name to ensure that we are still "in project".
realTop.className,
"fakeMethodForCrashGrouping",
/* fileName = */ stackTraceKey.toString(),
/* lineNumber = */ stackTraceKey.hashCode()
)
stackTrace = stackTrace.toMutableList().apply { add(0, fakeTop) }.toTypedArray()
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.squareup.workflow1

import com.squareup.workflow1.WorkflowInterceptor.RenderContextInterceptor
import com.squareup.workflow1.WorkflowInterceptor.RuntimeUpdate
import com.squareup.workflow1.WorkflowInterceptor.WorkflowSession
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
Expand Down

This file was deleted.

Loading
Loading