Skip to content

Commit 1bba215

Browse files
committed
Split Android checkout protocol module
Assisted-By: devx/6488e3d0-f47f-4171-a1c4-d2432b2a653c
1 parent 176e7bf commit 1bba215

60 files changed

Lines changed: 3791 additions & 2893 deletions

File tree

Some content is hidden

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

.github/CONTRIBUTING.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,17 @@ To check for lint issues without auto-correcting:
150150

151151
### Public API surface
152152

153-
The library's public API is tracked via a committed baseline at `platforms/android/lib/api/lib.api`, managed by the [binary-compatibility-validator](https://github.com/Kotlin/binary-compatibility-validator) Gradle plugin. The unified `Breaking Changes` CI workflow runs `./gradlew :lib:apiCheck` on every PR that touches Android sources and fails if the compiled public API diverges from the baseline.
153+
The Android-facing public APIs are tracked via committed baselines managed by the [binary-compatibility-validator](https://github.com/Kotlin/binary-compatibility-validator) Gradle plugin:
154+
155+
- `platforms/android/lib/api/lib.api` for `com.shopify:checkout-kit`.
156+
- `protocol/languages/kotlin/embedded-checkout-protocol/api/embedded-checkout-protocol.api` for `com.shopify:embedded-checkout-protocol`.
157+
158+
The unified `Breaking Changes` CI workflow runs `./gradlew apiCheck` on every PR that touches Android or Kotlin protocol sources and fails if the compiled public API diverges from the baselines.
154159

155160
If your change intentionally modifies the public API:
156161

157-
1. Run `dev android api dump` from the repo root (or `./gradlew :lib:apiDump` from `platforms/android/`) to regenerate the baseline.
158-
2. Review the diff in `platforms/android/lib/api/lib.api` alongside your code changes.
162+
1. Run `dev android api dump` from the repo root (or `./gradlew apiDump` from `platforms/android/`) to regenerate the baselines.
163+
2. Review the relevant `.api` diff alongside your code changes.
159164
3. Commit the updated `.api` file in the same PR.
160165

161166
If you did _not_ intend to change public API and `apiCheck` is failing, the diff shows what your change inadvertently affected — treat it as a signal that something in your PR has consumer-visible impact.
@@ -164,16 +169,16 @@ If you did _not_ intend to change public API and `apiCheck` is failing, the diff
164169

165170
Open a pull request with the following changes:
166171

167-
1. Bump the `versionName` in `platforms/android/lib/build.gradle`.
172+
1. Bump `checkoutKitAndroid` in `platforms/android/gradle/libs.versions.toml`.
168173
2. Add an entry to the top of `platforms/android/CHANGELOG.md`.
169-
3. If the React Native package should consume this Android SDK release, update `checkoutKit.nativeSdkVersions.android` in `platforms/react-native/modules/@shopify/checkout-kit-react-native/package.json` to the same version.
174+
3. Update `checkoutKit.nativeSdkVersions.android` in `platforms/react-native/modules/@shopify/checkout-kit-react-native/package.json` to the same lowercase SemVer.
170175

171176
Supported release versions are `X.Y.Z` and prerelease versions are `X.Y.Z-{alpha|beta|rc}.N`.
172177

173178
Once merged, run the [Release package workflow](../../actions/workflows/release.yml):
174179

175180
1. Select `Android` as the platform.
176-
2. Enter the expected version. The workflow reads the SDK version from `platforms/android/lib/build.gradle` and fails if the typed version does not match.
181+
2. Enter the expected version. The workflow reads the SDK version from `platforms/android/gradle/libs.versions.toml` and fails if the typed version does not match.
177182
3. Select `Dry run` first to review the release plan without creating a release.
178183
4. Rerun with `Draft release` to create a draft GitHub Release with the `android/`-prefixed tag (e.g. `android/3.0.1`) for human review.
179184
5. Publish the draft release when ready. Publishing the draft kicks off the [Android publish workflow](../../actions/workflows/android-publish.yml). **A manual approval by a maintainer is required before publication to Maven Central.**
@@ -195,7 +200,7 @@ The React Native package reads its published native SDK dependency versions from
195200
}
196201
```
197202

198-
When updating the Swift or Android SDK version that React Native should consume, update the matching `checkoutKit.nativeSdkVersions` entry in this package file. These values drive `RNShopifyCheckoutKit.podspec` for iOS and the module/sample Gradle dependencies for Android, so they must stay aligned with the published native SDK versions used by the React Native release.
203+
When updating the Swift or Android SDK version that React Native should consume, update the matching `checkoutKit.nativeSdkVersions` entry in this package file. These values drive `RNShopifyCheckoutKit.podspec` for iOS and the module/sample Gradle dependencies for Android, so they must stay aligned with the published native SDK versions used by the React Native release. Android CI uses the published Maven artifact by default, so `nativeSdkVersions.android` must stay on the published `com.shopify:checkout-kit` lowercase SemVer, not the Kotlin protocol calver.
199204

200205
### Public API surface
201206

.github/pull_request_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<details>
3333
<summary>Releasing a new Android version?</summary>
3434

35-
- [ ] I have bumped the `versionName` in `platforms/android/lib/build.gradle`
35+
- [ ] I have bumped `checkoutKitAndroid` in `platforms/android/gradle/libs.versions.toml`
3636
- [ ] I have updated `platforms/android/CHANGELOG.md`
3737
- [ ] I have updated the Gradle/Maven version snippets in `platforms/android/README.md`
3838

.github/scripts/validate-release-version

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,25 @@ json_version() {
4848
.github/scripts/package-json-version "$file"
4949
}
5050

51+
json_string_field() {
52+
local file="$1"
53+
local jq_filter="$2"
54+
55+
if ! value=$(jq -er "$jq_filter | strings | select(length > 0)" "$file"); then
56+
echo "::error file=$file::Could not extract version field." >&2
57+
exit 1
58+
fi
59+
60+
printf '%s\n' "$value"
61+
}
62+
63+
version_catalog_value() {
64+
local file="$1"
65+
local key="$2"
66+
67+
extract_first_match "$file" "s/^[[:space:]]*${key}[[:space:]]*=[[:space:]]*\"([^\"]+)\".*/\\1/p"
68+
}
69+
5170
check_same_version() {
5271
local expected="$1"
5372
local file="$2"
@@ -86,8 +105,13 @@ case "$PLATFORM_INPUT" in
86105
TAG_PREFIX="android/"
87106
PUBLISH_WORKFLOW="android-publish.yml"
88107

89-
ANDROID_VERSION_FILE="platforms/android/lib/build.gradle"
90-
VERSION=$(extract_first_match "$ANDROID_VERSION_FILE" 's/^[[:space:]]*def[[:space:]]+versionName[[:space:]]*=[[:space:]]*"([^"]+)".*/\1/p')
108+
ANDROID_VERSION_FILE="platforms/android/gradle/libs.versions.toml"
109+
RN_PACKAGE_FILE="platforms/react-native/modules/@shopify/checkout-kit-react-native/package.json"
110+
111+
VERSION=$(version_catalog_value "$ANDROID_VERSION_FILE" "checkoutKitAndroid")
112+
RN_ANDROID_VERSION=$(json_string_field "$RN_PACKAGE_FILE" '.checkoutKit.nativeSdkVersions.android')
113+
114+
check_same_version "$VERSION" "$RN_PACKAGE_FILE" "$RN_ANDROID_VERSION"
91115
;;
92116

93117
"React Native"|react-native|ReactNative|rn|RN)

.github/workflows/breaking-changes.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
cache: 'gradle'
7070

7171
- name: Check public Android API baseline
72-
run: ./gradlew :lib:apiCheck --console=plain
72+
run: ./gradlew apiCheck --console=plain
7373

7474
react-native:
7575
name: React Native

.github/workflows/rn-build-android.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ jobs:
4040
platforms/android/**/*.gradle*
4141
platforms/android/**/gradle-wrapper.properties
4242
platforms/android/gradle.properties
43+
protocol/languages/kotlin/**/*.gradle*
44+
protocol/languages/kotlin/**/*.toml
4345
platforms/react-native/package.json
4446
platforms/react-native/pnpm-lock.yaml
4547
platforms/react-native/sample/package.json

.github/workflows/rn-test-android.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ jobs:
4040
platforms/android/**/*.gradle*
4141
platforms/android/**/gradle-wrapper.properties
4242
platforms/android/gradle.properties
43+
protocol/languages/kotlin/**/*.gradle*
44+
protocol/languages/kotlin/**/*.toml
4345
platforms/react-native/package.json
4446
platforms/react-native/pnpm-lock.yaml
4547
platforms/react-native/sample/package.json

AGENTS.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
```
44
platforms/
55
swift/ # iOS Swift Package and CocoaPods sources
6-
android/ # Android library and sample apps
6+
android/ # Android library, embedded checkout protocol artifact, and sample apps
77
react-native/ # React Native wrapper
88
web/ # Web component package and sample app
99
protocol/ # cross-platform communication layer based on UCP
@@ -49,6 +49,7 @@ This applies when changes are made under:
4949
5050
- `platforms/swift/` — the iOS Swift SDK / CocoaPods sources
5151
- `platforms/android/` — the Android SDK / Maven artifact sources
52+
- `protocol/languages/kotlin/` — Kotlin protocol artifacts consumed by the Android SDK
5253
5354
It does **not** refer to the React Native wrapper platform folders:
5455
@@ -58,18 +59,18 @@ It does **not** refer to the React Native wrapper platform folders:
5859
### What `--local` does
5960
6061
- For React Native iOS, `--local` wires CocoaPods to the in-repo `platforms/swift/` sources via a local path instead of a released pod version.
61-
- For React Native Android, `--local` publishes/uses the in-repo `platforms/android/` SDK through Maven Local so Gradle resolves the local SDK artifact instead of a released Maven version.
62+
- For React Native Android, `--local` publishes/uses the in-repo Android SDK and Kotlin protocol artifacts through Maven Local so Gradle resolves the local `com.shopify:checkout-kit` and `com.shopify:embedded-checkout-protocol` artifacts instead of released Maven versions.
6263
6364
### When to use it
6465
6566
Use `--local` whenever you are validating React Native behavior that depends on unreleased native SDK changes, for example:
6667
6768
- a new Swift SDK API that the React Native iOS bridge calls
6869
- a new Android SDK API that the React Native Android bridge calls
69-
- generated protocol/model changes under the native SDKs that the React Native module consumes
70-
- any change in `platforms/swift/` or `platforms/android/` that has not yet been released and consumed through normal dependency versions
70+
- generated protocol/model changes under `protocol/languages/kotlin/` that the React Native module consumes through Android
71+
- any change in `platforms/swift/`, `platforms/android/`, or `protocol/languages/kotlin/` that has not yet been released and consumed through normal dependency versions
7172
72-
Re-run the relevant local workflow whenever `platforms/swift/` or `platforms/android/` changes, because the React Native sample/tests need to re-resolve those local native SDK sources/artifacts.
73+
Re-run the relevant local workflow whenever `platforms/swift/`, `platforms/android/`, or `protocol/languages/kotlin/` changes, because the React Native sample/tests need to re-resolve those local native SDK sources/artifacts.
7374
7475
```bash
7576
# iOS sample using local platforms/swift sources
@@ -79,11 +80,11 @@ dev rn ios --local
7980
dev rn android --local
8081
8182
# React Native Android unit tests using local platforms/android via Maven Local
82-
# `dev rn test android` publishes platforms/android/lib to ~/.m2 first, then runs the RN module tests.
83+
# `dev rn test android` publishes the Android SDK artifacts to ~/.m2 first, then runs the RN module tests.
8384
dev rn test android
8485
```
8586
86-
For ad-hoc Android Gradle test commands, publish the local Android SDK first and set `USE_LOCAL_SDK=1` so the React Native module resolves `com.shopify:checkout-kit:1.0.0` from Maven Local instead of the unreleased placeholder artifact:
87+
For ad-hoc Android Gradle test commands, publish the local Android SDK first and set `USE_LOCAL_SDK=1` so the React Native sample resolves the local `com.shopify:checkout-kit` and `com.shopify:embedded-checkout-protocol` artifacts from Maven Local:
8788

8889
```bash
8990
cd platforms/react-native
@@ -92,6 +93,8 @@ cd sample/android
9293
USE_LOCAL_SDK=1 ./gradlew :shopify_checkout-kit-react-native:testDebugUnitTest
9394
```
9495

96+
The React Native Android sample uses exclusive Maven Local resolution for those two `com.shopify` modules when `USE_LOCAL_SDK=1`. Keep that filtering in the sample Gradle build; duplicating exclusive repository filters for the same modules elsewhere can break dependency resolution.
97+
9598
## Sensitive configuration
9699

97100
Treat storefront environment and generated sample app configuration values as

dev.yml

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,25 @@ commands:
121121
subcommands:
122122
build:
123123
desc: Build the protocol target
124-
run: cd protocol/languages/swift && swift build
124+
run: |
125+
set -e
126+
root=$(pwd)
127+
cd protocol/languages/swift
128+
echo "Building Swift protocol..."
129+
swift build
130+
cd $root/protocol/languages/kotlin
131+
echo "Building Kotlin protocol..."
132+
../../../platforms/android/gradlew :embedded-checkout-protocol:build
125133
test:
126134
desc: Run protocol package tests
127135
run: |
128136
root=$(pwd)
129137
cd protocol/languages/swift
130138
echo "Running tests for Swift..."
131139
swift test
140+
cd $root/protocol/languages/kotlin
141+
echo "Running tests for Kotlin..."
142+
../../../platforms/android/gradlew :embedded-checkout-protocol:test
132143
cd $root/protocol
133144
echo "Running tests for TypeScript..."
134145
pnpm test
@@ -227,20 +238,20 @@ commands:
227238
open -a "Android Studio" "$project"
228239
229240
api:
230-
desc: Validate or update the public API baseline (lib/api/lib.api)
241+
desc: Validate or update the public Android API baselines
231242
run: |
232243
echo "Usage: dev android api {check|dump}"
233244
echo ""
234-
echo " check Verify public API matches the committed baseline"
235-
echo " dump Regenerate the baseline after intentional public API changes"
245+
echo " check Verify public APIs match the committed baselines"
246+
echo " dump Regenerate the baselines after intentional public API changes"
236247
exit 1
237248
subcommands:
238249
check:
239-
desc: Verify public API matches the committed baseline
240-
run: cd platforms/android && ./gradlew :lib:apiCheck
250+
desc: Verify public APIs match the committed baselines
251+
run: cd platforms/android && ./gradlew apiCheck
241252
dump:
242-
desc: Regenerate the baseline after intentional public API changes
243-
run: cd platforms/android && ./gradlew :lib:apiDump
253+
desc: Regenerate the baselines after intentional public API changes
254+
run: cd platforms/android && ./gradlew apiDump
244255

245256
# Swift
246257
swift:

0 commit comments

Comments
 (0)