Skip to main content

Project Setup

1. Why​

M0 is about proving the skeleton before any component exists:

  • two library modules plus a sample app;
  • four platforms (Android, iOS, desktop, web, per ADR-18);
  • CI that builds all of them.

Getting the Gradle structure right now saves fighting it for every later milestone. This note implements the module and platform parts of Architecture.

2. Shape​

Targets per module

ModuleandroidiosArm64 + iosSimulatorArm64jvm (desktop)wasmJs (web)
:camouflage-corelibrarylibrarylibrarylibrary
:camouflage-skin-minimallibrarylibrarylibrarylibrary
:camouflage-navigation3librarylibrarylibrarylibrary
:sample:sharedlibrary (consumed by :sample:androidApp)framework SampleSharedapplication (desktop window)binaries.executable() (browser)

iosX64 (Intel simulators) is left out, because Compose Multiplatform supports only 64-bit arm64 Macs for new work. Add it only if a contributor still uses an Intel Mac.

3. API​

This is the Gradle surface: what each file contains and why.

3.1 settings.gradle.kts​

rootProject.name = "camouflage-kotlin"
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") // projects.camouflageCore instead of ":camouflage-core"

pluginManagement {
includeBuild("build-logic")
repositories { google(); mavenCentral(); gradlePluginPortal() }
}
dependencyResolutionManagement {
repositories { google(); mavenCentral() }
versionCatalogs { // split catalogs, one per concern
create("kotlinLibs") { from(files("gradle/kotlin.versions.toml")) }
create("composeLibs") { from(files("gradle/compose.versions.toml")) }
create("androidLibs") { from(files("gradle/android.versions.toml")) }
create("toolLibs") { from(files("gradle/tools.versions.toml")) }
}
}
include(":camouflage-core", ":camouflage-skin-minimal", ":camouflage-navigation3", ":camouflage-skin-testing", ":camouflage-bom",
":sample:shared", ":sample:androidApp")

3.2 Version catalogs (gradle/*.versions.toml)​

CatalogEntries
kotlin.versions.tomlkotlin = "2.4.20"; plugins kotlin-multiplatform, kotlin-compose (Compose compiler, same version)
compose.versions.tomlcompose-multiplatform = "1.12.1"; libraries runtime, ui, foundation, ui-test (plus material-ripple later, for the Material skin only); plugins compose-multiplatform, compose-hot-reload
android.versions.tomlagp = "9.4.0", compileSdk = "37", minSdk = "24"; plugins android-application, android-kmp-library (com.android.kotlin.multiplatform.library)
tools.versions.tomlkotlinx-datetime (core's date types for the pickers, ADR-35), materialkolor = "5.0.1" (com.materialkolor:material-color-utilities), roborazzi, vanniktech-publish, dokka, detekt, kover

Compose libraries use explicit coordinates (org.jetbrains.compose.foundation:foundation, …) from the catalog, not the compose.* shortcuts, so versions are visible and catalog-driven.

3.3 Convention plugins (build-logic/)​

Designed to be extracted. This build-logic is the seed of a standalone, published convention-plugin project (e.g. srctool/gradle-conventions), built properly while doing Camouflage and extracted after M7. So:

  • plugin IDs are generic (com.srctool.*), and nothing inside mentions Camouflage;
  • project-specific values come from a small extension:
srctool {
namespacePrefix = "com.srctool.camouflage" // android namespace = prefix + module suffix
targets = setOf(Android, Ios, Jvm, WasmJs)
publishing { groupId = "com.srctool.camouflage"; repoUrl = "https://github.com/srctool/camouflage-kotlin" }
}
Plugin idAppliesUsed by
com.srctool.kmp.libraryKotlin Multiplatform, the Android-KMP library plugin, all four targets, explicitApi(), abiValidation, Detekt, Kovercore, skin-material
com.srctool.composethe Compose Multiplatform + Compose compiler plugins, and the base Compose dependenciescore, skin-material, sample:shared
com.srctool.publishvanniktech publish + Dokka + signing (see Publishing)core, skin-material, bom

Each is split into small configureXxx() functions that read SDK versions from the catalog (your convention-plugin style). The plugins get their own tests (Gradle TestKit functional tests on a tiny fixture project), so they're ready to publish when extracted.

com.srctool.kmp.library, the important part (values shown resolved from the srctool {} extension):

kotlin {
explicitApi()

android { // Android-KMP library plugin DSL (AGP 9)
namespace = srctool.namespacePrefix.get() + "." + project.name.removePrefix("camouflage-").replace('-', '.')
compileSdk = androidLibs.versions.compileSdk.get().toInt()
minSdk = androidLibs.versions.minSdk.get().toInt()
withHostTestBuilder {} // unit tests on the JVM (Robolectric screenshots)
}
iosArm64(); iosSimulatorArm64()
jvm()
@OptIn(ExperimentalWasmDsl::class)
wasmJs { browser() }

@OptIn(ExperimentalAbiValidation::class)
abiValidation() // checkKotlinAbi runs on `check`

compilerOptions { freeCompilerArgs.add("-Xexpect-actual-classes") }
}

3.4 Library dependencies​

ModulecommonMaincommonTest
:camouflage-coreruntime, ui, foundation, material-color-utilities (for fromSeed)kotlin("test"), ui-test (the common runComposeUiTest)
:camouflage-skin-minimalprojects.camouflageCore (as api) only. No Material artifacts.
:camouflage-navigation3projects.camouflageCore (as api), JetBrains' multiplatform Navigation 3 (navigation3-ui) + lifecycle-viewmodel-navigation3the same as core

There is deliberately no Material dependency in v1 (material3, material-ripple): core must stay visually neutral, and the Minimal skin draws everything itself. A Later Material skin adds only material-ripple (see Material Skin).

3.5 Sample app entry points​

PlatformWhereEntry
Android:sample:androidAppMainActivity → setContent { SampleApp() }
iOSsample/iosApp + iosMain of :sample:sharedfun MainViewController() = ComposeUIViewController { SampleApp() }, shown from SwiftUI
DesktopjvmMain of :sample:sharedfun main() = application { Window(::exitApplication, title = "Camouflage") { SampleApp() } }
WebwasmJsMain of :sample:sharedfun main() = ComposeViewport(document.body!!) { SampleApp() }

SampleApp() lives in commonMain. Add Compose Hot Reload to the desktop run: it's the fastest loop for live coding on camera.

3.6 CI (GitHub Actions)​

JobRunnerRuns
jvm-and-androidubuntu./gradlew check for android + jvm (tests, ABI check, Detekt, Kover)
webubuntu./gradlew wasmJsTest wasmJsBrowserDistribution (allowed to fail while Compose web is Beta, per ADR-18)
iosmacos./gradlew iosSimulatorArm64Test plus an xcodebuild build of iosApp

Use the Gradle build cache and configuration cache in every job.

4. Build steps​

  1. Create the repo layout from the Overview, then settings.gradle.kts and the four catalogs.
  2. Write the three convention plugins in build-logic with generic com.srctool.* IDs, the srctool {} extension, and TestKit tests.
  3. Create :camouflage-core with one public type (public data class CamoTheme(val placeholder: Int)) and :camouflage-skin-minimal using it, plus empty :camouflage-navigation3 and :camouflage-skin-testing modules (they fill in at M6 and M3).
  4. Create :sample:shared with SampleApp() showing a text, plus the four entry points. Run it on an Android emulator, an iOS simulator, a desktop window, and in the browser.
  5. Run ./gradlew updateKotlinAbi to create the first ABI dumps, and commit them.
  6. Add the three CI jobs, including the dependency-layer check (ADR-27): a Gradle task that fails if a module depends on its own layer or a higher one.
  7. Add Detekt with a baseline, Kover with a threshold (start at 0, raise to 75% for core logic from M2), and Dokka.

Done when

  • ./gradlew check passes locally, and all three CI jobs are green (web may be yellow).
  • The sample opens on Android, iOS, desktop and web.
  • Changing a public signature in core fails checkKotlinAbi until updateKotlinAbi is run.
  • :camouflage-core has no dependency on :camouflage-skin-minimal, and neither module depends on any Material artifact (check with ./gradlew :camouflage-core:dependencies).

5. Edge cases​

CaseDecided behavior
Family packages (ADR-26)Blueprint, Storybook, camouflage-generator (a Gradle plugin, in its own included build next to build-logic), templates (camouflage-camera) and camouflage-filesystem join later as modules in this repo, depending on project(":camouflage-core"). They have their own versions, and the BOM pins them at versions tested together with core (ADR-27).
AGP 9 forbids KMP + com.android.application in one moduleThat's why the Android app is :sample:androidApp, separate from :sample:shared.
A dependency lacks one of the four targetsDon't add it to core or the skin. Find a multiplatform alternative, or put the feature behind expect/actual. It's checked at M0 for MaterialKolor (supported).
The web build breaks because of a Compose web (Beta) changeThe web job is allowed to fail. Fix it in a follow-up. It never blocks a release of the stable targets (ADR-18).
Building iOS locally without a MacNot possible. CI's macOS job covers it. The other three targets build anywhere.
ABI validation is experimentalIt's opted in with @OptIn(ExperimentalAbiValidation::class). If the DSL changes in a Kotlin update, fix the convention plugin in one place.
An Intel Mac contributorAdd iosX64() locally, and don't commit it unless needed.

1. Why​

This note settles the repository, the TypeScript configuration, the tools and the publishing plan for srctool/camouflage-web, so the spike and the first milestones start from the same setup. It implements the module and platform parts of the base Architecture note.

2. Shape​

camouflage-web/ # a submodule of srctool/camouflage (web-lib/), like kotlin-lib and dart-lib
├── package.json # private root; scripts for every package
├── pnpm-workspace.yaml
├── tsconfig.base.json # strict, shared by every package
├── packages/
│ ├── core/ # layer 1: theme, provider, skin contract, behavior, components
│ ├── skin-minimal/ skin-material/ skin-cupertino/ skin-fluent/ skin-carbon/ # layer 2
│ └── charts/ # layer 2
├── apps/
│ ├── storybook/ # galleries and screenshot scenarios
│ ├── sample/ # the sample app, also built for Tauri
│ └── ssr-sample/ # server rendering: plain Node and Next.js
├── tools/ # contract generation, size budget, release scripts
└── .github/workflows/ # CI and release

Layers. core depends on no skin. Each skin depends only on core. charts depends on core and reads its skin preset by name, as in the other libraries. A script checks this (the equivalent of checkModuleLayers).

3. API​

3.1 TypeScript configuration​

tsconfig.base.json turns on everything that makes the contract trustworthy:

{
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "Bundler",
"strict": true,
"exactOptionalPropertyTypes": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true,
"verbatimModuleSyntax": true,
"isolatedDeclarations": true,
"experimentalDecorators": false,
"useDefineForClassFields": true
}
}
  • isolatedDeclarations and verbatimModuleSyntax keep the public types explicit and the build fast.
  • Skins end with satisfies CamoSkin, so the compiler lists missing renderers.
  • Decided at W0: static properties with declare fields, no decorators. The properties are typed by declare (so no class field overwrites the accessor Lit defines), the output needs no decorator transform in any tool (Vite, Vitest, the SSR build, Storybook), and the Custom Elements Manifest reads the JSDoc. isolatedDeclarations is on, so each export has an explicit type.

3.2 Packages​

RuleWhy
ESM only, one exports map per packageno dual-package problems; smaller output
"sideEffects": false, except each skin's register entry and the element-defining entrybundlers can drop unused skins and renderers
Elements are defined from one define entry, guarded (if (!customElements.get(...)))importing a type never registers elements; two copies of the package don't throw
Types are published with each package (.d.ts from isolatedDeclarations)the contract is typed for every consumer
The Custom Elements Manifest is published with coredocs, IDE support and framework wrappers can read it

3.3 Tooling​

NeedTool
BuildVite library mode (or tsup), one entry per package
Unit and behavior testsVitest in browser mode with Playwright (Chromium, Firefox, WebKit)
ScreenshotsPlaywright screenshots of Storybook scenarios, compared per skin, mode and browser
Accessibilityaxe-core inside the same scenarios
Lint and formatESLint with the Lit and TypeScript rules, and a custom rule against literal colors and sizes in renderers; Prettier
Docs and previewsStorybook for web components, fed by the Custom Elements Manifest
Size budgeta script that fails CI when a component or skin passes its budget

3.4 Tests that mirror the other libraries​

Kotlin and DartWeb
goldens per skin, mode and gallerythe same scenario list, rendered in Storybook and captured with Playwright
assertRendererAppliesBehaviora test that a renderer keeps the element's behavior (click, keyboard, disabled, loading)
the no-literals testan ESLint rule and a test that scans the built renderers for color and size literals
tap-target and label guidelinesaxe plus a minimum-size check (48 px target)
Reduce Transparency and blur-off goldensPlaywright with prefers-reduced-transparency and with blur disabled

3.5 Publishing​

  • Registry: npm, under the @srctool scope (the npm organization exists, created by the owner; packages are @srctool/camouflage-core, @srctool/camouflage-skin-minimal and so on), with provenance from GitHub Actions (OIDC, no stored tokens), as pub.dev and Maven Central are done for the others.
  • Versions: 0.x, in lockstep with the Kotlin and Dart releases once the web port reaches parity. A package's 0.2.0 means the same contract as Kotlin and Dart 0.2.0. Before parity, previews use 0.2.0-alpha.N, never a number that claims parity.
  • Tags: <folder>-v<version> per package (core-v0.2.0-alpha.1, skin-minimal-v0.2.0-alpha.1), like camouflage_core-v0.1.0 on pub.dev. tools/release-check.mjs fails the release if the tag and the package version differ, and, before parity, if the version is anything but 0.x.y-alpha.N (dist-tag alpha).
  • Workflow: release.yml runs on the tag in the npm environment, verifies, packs with pnpm and runs npm publish --provenance; it stays a dry run (DRY_RUN) until the owner decides to publish. The owner's one-time setup (reserve each name, then the Trusted Publisher on npmjs.com) is in the web repository's docs/publishing.md.
  • The submodule: srctool/camouflage adds web-lib/ and the sync script's wrapper, as for the other two.

3.6 Where Storybook lives: inside the usage site​

The component gallery is Storybook for web components, hosted in the usage site (camouflage.srctool.com), not on its own domain. That site is a Docusaurus site deployed to Cloudflare Pages by .github/workflows/docs.yml in srctool/camouflage.

Path. The static Storybook build is placed in docs/usage/static/web/ so Cloudflare serves it at /web/ (for example /web/?path=/story/button--solid), and the usage docs link to it from the component pages and embed the relevant stories where it helps. Docusaurus copies static/ as it is, so the Storybook output needs no processing.

How the build gets there (decided at the end of W0: option A; the W0 Storybook already builds with base /web/ and apps/storybook/serve.mjs serves it under that path to test it):

OptionHowTrade-off
A. Pinned submodule build (decided)the camouflage repo adds web-lib/ (like kotlin-lib/ and dart-lib/); the docs workflow checks out the submodule, builds Storybook and copies it into docs/usage/static/web/ before the Docusaurus buildreproducible: the gallery always matches the pinned web version; the workflow needs submodule checkout and a pnpm step
B. Release artifactthe web repo publishes the Storybook build as a release asset; the docs workflow downloads a pinned versionno web build inside the docs workflow; one more release step to keep in sync
C. Separate deploy, proxiedthe web repo deploys its own Pages project and the usage site proxies /web/ to itlive on every web commit, but two deployments and a routing rule

Rules for either option:

  • Storybook uses a base path of /web/ so assets resolve under the usage site.
  • The pull-request build of the usage site builds the gallery too, so a broken story fails the check (as the docs build does now); only pushes to main deploy.
  • The gallery has no secrets and is static, so it needs no change to the Cloudflare project.
  • Stories are the same scenarios as the Kotlin and Dart goldens, so the three galleries can be compared side by side.

4. Build steps​

  1. Initialize the workspace, tsconfig.base.json, lint, formatter and CI (typecheck, lint, test).
  2. Add core with the spike's provider and button; add skin-minimal and skin-cupertino with the same.
  3. Add Storybook and the first screenshot scenario; add the layer check and the size budget.
  4. Add the ssr-sample app (plain Node first, then Next.js).
  5. Add the release workflow with provenance, dry-run only until W10.

Done when

  • pnpm check runs typecheck, lint, tests and the layer check on a clean clone.
  • CI runs the browser tests on Chromium, Firefox and WebKit.
  • A package build shows no side effects outside the define and register entries.

5. Edge cases​

CaseDecided behavior
A consumer uses a bundler that ignores sideEffectsDocument that the define and register entries are explicit imports; the main entries are always safe to import.
The same page loads two versions of coreThe context key is shared, define is guarded, and a version mismatch warns once.
A framework wants typed wrappersGenerate them from the manifest in a separate package later; do not hand-write them.
Node-side imports (SSR)Every package has a Node-safe entry: no window or document at import time.