Skip to content

Commit 3c493f3

Browse files
Move workflow-runtime-android into android source set in workflow-runtime module.
This keeps all the runtime code in the same module, reducing the number of dependencies external code need to specify, and making it possible for our android-specific runtime code to directly access internal code in the runtime module, and satisfy more specific expect/actuals. It also lets us write android-specific tests for runtime code. Additionally, this helps pave the way for go/compose-based-workflows.
1 parent eaf1925 commit 3c493f3

File tree

28 files changed

+144
-108
lines changed

28 files changed

+144
-108
lines changed

artifacts.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@
7171
"javaVersion": 8,
7272
"publicationName": "kotlinMultiplatform"
7373
},
74+
{
75+
"gradlePath": ":workflow-runtime",
76+
"group": "com.squareup.workflow1",
77+
"artifactId": "workflow-runtime-android",
78+
"description": "Workflow Runtime",
79+
"packaging": "aar",
80+
"javaVersion": 8,
81+
"publicationName": "android"
82+
},
7483
{
7584
"gradlePath": ":workflow-runtime",
7685
"group": "com.squareup.workflow1",
@@ -125,15 +134,6 @@
125134
"javaVersion": 8,
126135
"publicationName": "kotlinMultiplatform"
127136
},
128-
{
129-
"gradlePath": ":workflow-runtime-android",
130-
"group": "com.squareup.workflow1",
131-
"artifactId": "workflow-runtime-android",
132-
"description": "Workflow Runtime Android",
133-
"packaging": "aar",
134-
"javaVersion": 8,
135-
"publicationName": "maven"
136-
},
137137
{
138138
"gradlePath": ":workflow-rx2",
139139
"group": "com.squareup.workflow1",

settings.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ include(
6464
":workflow-config:config-jvm",
6565
":workflow-core",
6666
":workflow-runtime",
67-
":workflow-runtime-android",
6867
":workflow-rx2",
6968
":workflow-testing",
7069
":workflow-tracing",

workflow-runtime-android/README.md

Lines changed: 0 additions & 11 deletions
This file was deleted.

workflow-runtime-android/api/workflow-runtime-android.api

Lines changed: 0 additions & 10 deletions
This file was deleted.

workflow-runtime-android/build.gradle.kts

Lines changed: 0 additions & 35 deletions
This file was deleted.

workflow-runtime-android/gradle.properties

Lines changed: 0 additions & 3 deletions
This file was deleted.

workflow-runtime/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ This module contains the core APIs and logic for running workflows.
55
## Kotlin Multiplatform
66

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

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

1616
```bash
1717
./gradlew build -Pworkflow.targets=jvm

workflow-runtime/build.gradle.kts

Lines changed: 71 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,94 @@
1+
import com.android.build.api.dsl.androidLibrary
12
import com.squareup.workflow1.buildsrc.iosWithSimulatorArm64
23

34
plugins {
45
id("kotlin-multiplatform")
6+
id("com.android.kotlin.multiplatform.library")
57
id("published")
68
id("app.cash.burst")
79
}
810

911
kotlin {
12+
// Needed for expect class Lock, which is not public API, so this doesn't add any binary compat
13+
// risk.
14+
compilerOptions.freeCompilerArgs.add("-Xexpect-actual-classes")
15+
1016
val targets = project.findProperty("workflow.targets") ?: "kmp"
1117
if (targets == "kmp" || targets == "ios") {
1218
iosWithSimulatorArm64()
1319
}
1420
if (targets == "kmp" || targets == "jvm") {
1521
jvm {}
1622
}
23+
if (targets == "kmp" || targets == "android") {
24+
androidLibrary {
25+
namespace = "com.squareup.workflow1.android"
26+
testNamespace = "$namespace.test"
27+
28+
compileSdk = libs.versions.compileSdk.get().toInt()
29+
minSdk = libs.versions.minSdk.get().toInt()
30+
31+
withDeviceTestBuilder {
32+
sourceSetTreeName = "test"
33+
}.configure {
34+
instrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
35+
36+
// Disable transition and rotation animations.
37+
animationsDisabled = true
38+
}
39+
}
40+
}
1741
if (targets == "kmp" || targets == "js") {
1842
js(IR) { browser() }
1943
}
2044

21-
// Needed for expect class Lock, which is not public API, so this doesn't add any binary compat
22-
// risk.
23-
compilerOptions.freeCompilerArgs.add("-Xexpect-actual-classes")
24-
}
45+
sourceSets {
46+
commonMain {
47+
dependencies {
48+
api(project(":workflow-core"))
49+
api(libs.kotlinx.coroutines.core)
50+
}
51+
}
52+
53+
commonTest {
54+
dependencies {
55+
implementation(libs.kotlinx.coroutines.test.common)
56+
implementation(libs.kotlin.test.core)
57+
}
58+
}
59+
60+
androidMain {
61+
dependencies {
62+
// Add Android-specific dependencies here. Note that this source set depends on
63+
// commonMain by default and will correctly pull the Android artifacts of any KMP
64+
// dependencies declared in commonMain.
65+
val composeBom = project.dependencies.platform(libs.androidx.compose.bom)
2566

26-
dependencies {
27-
commonMainApi(project(":workflow-core"))
28-
commonMainApi(libs.kotlinx.coroutines.core)
67+
api(libs.androidx.compose.ui.android)
68+
api(libs.androidx.lifecycle.viewmodel.savedstate)
2969

30-
commonTestImplementation(libs.kotlinx.coroutines.test.common)
31-
commonTestImplementation(libs.kotlin.test.core)
70+
implementation(composeBom)
71+
}
72+
}
73+
74+
getByName("androidDeviceTest") {
75+
dependencies {
76+
implementation(project(":workflow-ui:internal-testing-android"))
77+
78+
implementation(libs.androidx.test.espresso.core)
79+
implementation(libs.androidx.test.junit)
80+
implementation(libs.squareup.leakcanary.instrumentation)
81+
82+
implementation(libs.androidx.activity.ktx)
83+
implementation(libs.androidx.lifecycle.viewmodel.ktx)
84+
implementation(libs.androidx.test.core)
85+
implementation(libs.androidx.test.truth)
86+
implementation(libs.kotlin.test.core)
87+
implementation(libs.kotlin.test.jdk)
88+
implementation(libs.kotlinx.coroutines.android)
89+
implementation(libs.kotlinx.coroutines.test)
90+
implementation(libs.squareup.papa)
91+
}
92+
}
93+
}
3294
}

0 commit comments

Comments
 (0)