Skip to content

ci: build core SDK once and share Maven Local across kit matrix - #747

Open
jamesnrokt wants to merge 2 commits into
mainfrom
ci/share-core-maven-local-publish
Open

ci: build core SDK once and share Maven Local across kit matrix#747
jamesnrokt wants to merge 2 commits into
mainfrom
ci/share-core-maven-local-publish

Conversation

@jamesnrokt

Copy link
Copy Markdown
Collaborator

Summary

All 22 build-kits matrix jobs each ran ./gradlew publishMavenPublicationToMavenLocal, rebuilding the identical core SDK 22 times per workflow run.

This adds a single publish-core job that does the publish once, archives ~/.m2/repository, and uploads it as an artifact. The matrix jobs download and untar it into $HOME/.m2 instead of rebuilding.

Changes

  • New publish-core job: publishes core SDK → tar -czf maven-local.tar.gz → uploads as maven-local-core (1-day retention, compression-level: 0 since the tar is already gzipped).
  • build-kits now needs: [load-matrix, publish-core]; its Gradle publish step is replaced by download + untar.
  • Quoted $GITHUB_ENV to satisfy shellcheck SC2086, which the pre-existing step tripped.

Why the artifact is complete

The root publish emits exactly four coordinates — android-core, android-kit-base, android-kit-plugin, android-plugin — plus their maven-metadata-local.xml. Nothing else writes to ~/.m2/repository (Gradle's dependency cache lives in ~/.gradle), so archiving the whole repository dir can't miss anything. KitPlugin restricts mavenLocal() to includeGroup 'com.mparticle' and excludes that group from Maven Central, so those four are precisely what kit builds need from there.

Testing

Published to an isolated repo at throwaway version 6.0.0-citest, tarred (1.2 MB), restored, and confirmed diff -r identical. Then built both consumer paths against only the restored copy via -Dmaven.repo.local:

  • :kits:android-adjust:adjust-5:testRelease (settings-kits.gradle) — BUILD SUCCESSFUL
  • :kits:android-adjust:adjust-5:example-kotlin:assembleDebug (settings-kit-examples.gradle) — BUILD SUCCESSFUL

Since 6.0.0-citest exists nowhere else, resolution demonstrably came from the tarball. trunk check clean on the changed file.

Only adjust-5 was exercised locally; the other 21 kits resolve com.mparticle:* through the same KitPlugin mechanism, so this PR's own workflow run is the real proof.

Trade-off

Matrix jobs now wait on publish-core before starting, but this drops 21 core SDK builds. The publish is ~22s warm locally and several minutes cold on a runner with no Gradle cache.

Not included

Deliberately out of scope, happy to follow up:

  1. The same duplicate publish exists in pull-request.yml (lint, kotlin-lint, kit-compatibility) and daily.yml — 6 more redundant core builds, two on macos-latest at 10× billing.
  2. build-kits.yml has no Gradle caching at all, so every matrix job still cold-downloads third-party dependencies. Likely a bigger win than this change, but needs a decision on cache-write scoping.

🤖 Generated with Claude Code

All 22 build-kits matrix jobs ran ./gradlew
publishMavenPublicationToMavenLocal, rebuilding the same core SDK 22
times per run.

Add a single publish-core job that runs the publish once, archives
~/.m2/repository (1.2 MB), and uploads it as an artifact. The matrix
jobs now download and untar it into $HOME/.m2 instead of rebuilding.

The root publish emits exactly four coordinates - android-core,
android-kit-base, android-kit-plugin and android-plugin - plus their
maven-metadata-local.xml. Nothing else writes to ~/.m2/repository
(Gradle's dependency cache lives in ~/.gradle), so archiving the whole
repository dir cannot miss anything. KitPlugin restricts mavenLocal()
to includeGroup 'com.mparticle' and excludes that group from Maven
Central, so those four are precisely what the kit builds need.

Also quote $GITHUB_ENV to satisfy shellcheck SC2086, which the
pre-existing step tripped.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@jamesnrokt
jamesnrokt requested a review from a team as a code owner July 30, 2026 14:31
@cursor

cursor Bot commented Jul 30, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
CI-only workflow wiring with no runtime or SDK behavior changes; main risk is artifact restore failing and breaking kit builds until the workflow is fixed.

Overview
build-kits.yml now publishes the core SDK once instead of running publishMavenPublicationToMavenLocal in every matrix job (~22 redundant builds per run).

A new publish-core job checks out, sets version from VERSION, runs the publish, tars ~/.m2/repository as maven-local.tar.gz, and uploads maven-local-core (1-day retention, compression-level: 0). build-kits depends on publish-core, downloads that artifact, and restores it under $HOME/.m2 before the existing kit tests and example builds (still using -Pmparticle.kit.mparticleFromMavenLocalOnly=true).

Matrix jobs start only after publish-core finishes, trading a short gate for dropping ~21 duplicate core builds. $GITHUB_ENV redirects are quoted for shellcheck SC2086.

Reviewed by Cursor Bugbot for commit 83df1ba. Bugbot is set up for automated code reviews on this repo. Configure here.

The semgrep security check blocks unpinned action refs. Pin the two new
uses to commit SHAs:

  actions/upload-artifact   043fb46 (v7.0.1)
  actions/download-artifact 37930b1 (v7.0.0)

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant