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
| Module | android | iosArm64 + iosSimulatorArm64 | jvm (desktop) | wasmJs (web) |
|---|---|---|---|---|
:camouflage-core | library | library | library | library |
:camouflage-skin-minimal | library | library | library | library |
:camouflage-navigation3 | library | library | library | library |
:sample:shared | library (consumed by :sample:androidApp) | framework SampleShared | application (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)
| Catalog | Entries |
|---|---|
kotlin.versions.toml | kotlin = "2.4.20"; plugins kotlin-multiplatform, kotlin-compose (Compose compiler, same version) |
compose.versions.toml | compose-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.toml | agp = "9.4.0", compileSdk = "37", minSdk = "24"; plugins android-application, android-kmp-library (com.android.kotlin.multiplatform.library) |
tools.versions.toml | kotlinx-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 id | Applies | Used by |
|---|---|---|
com.srctool.kmp.library | Kotlin Multiplatform, the Android-KMP library plugin, all four targets, explicitApi(), abiValidation, Detekt, Kover | core, skin-material |
com.srctool.compose | the Compose Multiplatform + Compose compiler plugins, and the base Compose dependencies | core, skin-material, sample:shared |
com.srctool.publish | vanniktech 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
| Module | commonMain | commonTest |
|---|---|---|
:camouflage-core | runtime, ui, foundation, material-color-utilities (for fromSeed) | kotlin("test"), ui-test (the common runComposeUiTest) |
:camouflage-skin-minimal | projects.camouflageCore (as api) only. No Material artifacts. | |
:camouflage-navigation3 | projects.camouflageCore (as api), JetBrains' multiplatform Navigation 3 (navigation3-ui) + lifecycle-viewmodel-navigation3 | the 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
| Platform | Where | Entry |
|---|---|---|
| Android | :sample:androidApp | MainActivity → setContent { SampleApp() } |
| iOS | sample/iosApp + iosMain of :sample:shared | fun MainViewController() = ComposeUIViewController { SampleApp() }, shown from SwiftUI |
| Desktop | jvmMain of :sample:shared | fun main() = application { Window(::exitApplication, title = "Camouflage") { SampleApp() } } |
| Web | wasmJsMain of :sample:shared | fun 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)
| Job | Runner | Runs |
|---|---|---|
jvm-and-android | ubuntu | ./gradlew check for android + jvm (tests, ABI check, Detekt, Kover) |
web | ubuntu | ./gradlew wasmJsTest wasmJsBrowserDistribution (allowed to fail while Compose web is Beta, per ADR-18) |
ios | macos | ./gradlew iosSimulatorArm64Test plus an xcodebuild build of iosApp |
Use the Gradle build cache and configuration cache in every job.
4. Build steps
- Create the repo layout from the Overview, then
settings.gradle.ktsand the four catalogs. - Write the three convention plugins in
build-logicwith genericcom.srctool.*IDs, thesrctool {}extension, and TestKit tests. - Create
:camouflage-corewith one public type (public data class CamoTheme(val placeholder: Int)) and:camouflage-skin-minimalusing it, plus empty:camouflage-navigation3and:camouflage-skin-testingmodules (they fill in at M6 and M3). - Create
:sample:sharedwithSampleApp()showing a text, plus the four entry points. Run it on an Android emulator, an iOS simulator, a desktop window, and in the browser. - Run
./gradlew updateKotlinAbito create the first ABI dumps, and commit them. - 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.
- 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 checkpasses 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
checkKotlinAbiuntilupdateKotlinAbiis run. -
:camouflage-corehas no dependency on:camouflage-skin-minimal, and neither module depends on any Material artifact (check with./gradlew :camouflage-core:dependencies).
5. Edge cases
| Case | Decided 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 module | That's why the Android app is :sample:androidApp, separate from :sample:shared. |
| A dependency lacks one of the four targets | Don'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) change | The 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 Mac | Not possible. CI's macOS job covers it. The other three targets build anywhere. |
| ABI validation is experimental | It'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 contributor | Add 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
}
}
isolatedDeclarationsandverbatimModuleSyntaxkeep the public types explicit and the build fast.- Skins end with
satisfies CamoSkin, so the compiler lists missing renderers. - Decided at W0:
static propertieswithdeclarefields, no decorators. The properties are typed bydeclare(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.isolatedDeclarationsis on, so each export has an explicit type.
3.2 Packages
| Rule | Why |
|---|---|
ESM only, one exports map per package | no dual-package problems; smaller output |
"sideEffects": false, except each skin's register entry and the element-defining entry | bundlers 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 core | docs, IDE support and framework wrappers can read it |
3.3 Tooling
| Need | Tool |
|---|---|
| Build | Vite library mode (or tsup), one entry per package |
| Unit and behavior tests | Vitest in browser mode with Playwright (Chromium, Firefox, WebKit) |
| Screenshots | Playwright screenshots of Storybook scenarios, compared per skin, mode and browser |
| Accessibility | axe-core inside the same scenarios |
| Lint and format | ESLint with the Lit and TypeScript rules, and a custom rule against literal colors and sizes in renderers; Prettier |
| Docs and previews | Storybook for web components, fed by the Custom Elements Manifest |
| Size budget | a script that fails CI when a component or skin passes its budget |
3.4 Tests that mirror the other libraries
| Kotlin and Dart | Web |
|---|---|
| goldens per skin, mode and gallery | the same scenario list, rendered in Storybook and captured with Playwright |
assertRendererAppliesBehavior | a test that a renderer keeps the element's behavior (click, keyboard, disabled, loading) |
| the no-literals test | an ESLint rule and a test that scans the built renderers for color and size literals |
| tap-target and label guidelines | axe plus a minimum-size check (48 px target) |
| Reduce Transparency and blur-off goldens | Playwright with prefers-reduced-transparency and with blur disabled |
3.5 Publishing
- Registry: npm, under the
@srctoolscope (the npm organization exists, created by the owner; packages are@srctool/camouflage-core,@srctool/camouflage-skin-minimaland 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's0.2.0means the same contract as Kotlin and Dart0.2.0. Before parity, previews use0.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), likecamouflage_core-v0.1.0on pub.dev.tools/release-check.mjsfails the release if the tag and the package version differ, and, before parity, if the version is anything but0.x.y-alpha.N(dist-tagalpha). - Workflow:
release.ymlruns on the tag in thenpmenvironment, verifies, packs with pnpm and runsnpm 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'sdocs/publishing.md. - The submodule:
srctool/camouflageaddsweb-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):
| Option | How | Trade-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 build | reproducible: the gallery always matches the pinned web version; the workflow needs submodule checkout and a pnpm step |
| B. Release artifact | the web repo publishes the Storybook build as a release asset; the docs workflow downloads a pinned version | no web build inside the docs workflow; one more release step to keep in sync |
| C. Separate deploy, proxied | the web repo deploys its own Pages project and the usage site proxies /web/ to it | live 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
maindeploy. - 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
- Initialize the workspace,
tsconfig.base.json, lint, formatter and CI (typecheck, lint, test). - Add
corewith the spike's provider and button; addskin-minimalandskin-cupertinowith the same. - Add Storybook and the first screenshot scenario; add the layer check and the size budget.
- Add the
ssr-sampleapp (plain Node first, then Next.js). - Add the release workflow with provenance, dry-run only until W10.
Done when
-
pnpm checkruns 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
defineandregisterentries.
5. Edge cases
| Case | Decided behavior |
|---|---|
A consumer uses a bundler that ignores sideEffects | Document that the define and register entries are explicit imports; the main entries are always safe to import. |
The same page loads two versions of core | The context key is shared, define is guarded, and a version mismatch warns once. |
| A framework wants typed wrappers | Generate 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. |