Skip to content

Auto-wire generated sources into compilation#288

Open
kirich1409 wants to merge 2 commits into
developfrom
feat/249-autowire-generated-sources
Open

Auto-wire generated sources into compilation#288
kirich1409 wants to merge 2 commits into
developfrom
feat/249-autowire-generated-sources

Conversation

@kirich1409

@kirich1409 kirich1409 commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

What changed

FeaturedPlugin and FeaturedApplicationPlugin now register their generated source directories into the consuming module's compilation automatically — applying the plugins requires zero manual srcDir/dependsOn boilerplate.

  • New GeneratedSourceWiring.kt with per-project-type helpers:
    • KMP commonMain and Kotlin/JVM main receive a task-carrying Provider<Directory> (task.flatMap { it.outputDir }); Gradle auto-infers the dependency for every consumer (compile*Kotlin*, *SourcesJar, metadata, …).
    • Plain AGP (com.android.application/library) receives a resolved File plus an explicit dependsOn — AGP's source set rejects providers at configuration time.
    • com.android.kotlin.multiplatform.library is covered by the KMP branch (it co-applies org.jetbrains.kotlin.multiplatform).
  • generateFeaturedRegistry now exposes an @OutputDirectory (dedicated generated/featured/registry dir, distinct from generateConfigParam's commonMain to avoid overlapping outputs), so the aggregator wires via the same task-carrying-provider mechanism.
  • Removed the now-redundant manual srcDir/dependsOn wiring from the sample feature modules and the shared aggregator (dogfood proof).
  • Docs updated (root + plugin CLAUDE.md, task KDoc) to describe auto-wiring.

Why

Closes #249. Previously a consumer had to hand-wire tasks.named("generateConfigParam") into a source set and add an explicit dependsOn — awkward on AGP 9 (kotlin { sourceSets["main"] } fails; android.sourceSets["main"].kotlin.srcDir(provider) is rejected). The plugin can detect the project type and wire correctly itself; the previously-documented "manual wiring is intentional" rationale is disproven.

Release Notes

### Changed

  • The Featured Gradle plugins now auto-wire generated sources into compilation. Consumer modules no longer need a manual sourceSets … srcDir(tasks.named("generateConfigParam")) / generateFeaturedRegistry declaration — applying dev.androidbroadcast.featured / dev.androidbroadcast.featured.application is sufficient. Existing manual wiring remains harmless (deduped) but can be deleted.

How to test

Clean build proves zero-boilerplate wiring across all supported project shapes (all green):

./gradlew clean
./gradlew :featured-gradle-plugin:test            # 321 tests incl. GeneratedSourceWiringTest (per-shape compile-proof)
./gradlew :sample:feature-ui:assemble             # KMP dogfood, manual wiring removed
./gradlew :sample:android-app:assembleDebug       # AGP consumer end-to-end (pulls KMP-android-library feature modules)
./gradlew :sample:shared:assemble                 # aggregator dogfood
./gradlew spotlessCheck

Status

Gate Result
/check (clean build + tests + spotless) ✅ all green
/finalize (review→fix→simplify) ✅ PASS — 1 round, 6 findings fixed
/acceptance (build-proof contract) ✅ VERIFIED

Acknowledged WARNs (see swarm-report/249-finalize.md): no dedicated com.android.kotlin.multiplatform.library TestKit fixture (covered end-to-end by the sample dogfood), no-supported-plugin silent no-wiring (misuse case), AGP dependsOn predicate may miss lint/sources-jar for plain-AGP consumers (untested low-likelihood edge).

Build-config/codegen-wiring change with no runtime behavior change — the proof is that modules compile and the sample app builds with all manual wiring deleted.

Artifacts (gitignored, local)

  • Plan/approach: swarm-report/249-autowire-state.md
  • Finalize: swarm-report/249-finalize.md
  • Acceptance: swarm-report/249-acceptance.md

🤖 Generated with Claude Code

Review in cubic

@kirich1409 kirich1409 added enhancement New feature or request gradle-plugin featured-gradle-plugin work sample Sample app status:in-progress Issue status: status:in-progress labels Jun 13, 2026
@kirich1409 kirich1409 marked this pull request as ready for review June 13, 2026 06:49

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 41 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="featured-gradle-plugin/src/test/fixtures/aggregator-multi-module-project/app/src/main/kotlin/WiringProof.kt">

<violation number="1" location="featured-gradle-plugin/src/test/fixtures/aggregator-multi-module-project/app/src/main/kotlin/WiringProof.kt:3">
P3: Comment references wrong output directory: GeneratedFeaturedRegistry lives at build/generated/featured/registry, not build/generated/featured/commonMain</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

@kirich1409 kirich1409 force-pushed the feat/249-autowire-generated-sources branch from 476b6b8 to 92f7f0f Compare June 13, 2026 07:16
@kirich1409 kirich1409 self-assigned this Jun 13, 2026
@kirich1409 kirich1409 force-pushed the feat/249-autowire-generated-sources branch from 92f7f0f to 47395a6 Compare June 13, 2026 07:38
@androidbroadcast androidbroadcast deleted a comment from cubic-dev-ai Bot Jun 13, 2026
kirich1409 and others added 2 commits June 13, 2026 11:00
FeaturedPlugin and FeaturedApplicationPlugin now register their generated
source directories into the consuming module's compilation automatically, so
applying the plugins requires zero manual srcDir/dependsOn boilerplate.

- New GeneratedSourceWiring.kt with per-project-type helpers: KMP commonMain
  and Kotlin/JVM main receive a task-carrying DirectoryProperty provider
  (Gradle auto-infers the dependency for every consumer); plain AGP receives a
  resolved File plus an explicit dependsOn (its source set rejects providers).
- generateFeaturedRegistry now exposes an @OutputDirectory (dedicated
  generated/featured/registry dir) so the aggregator wires via the same
  task-carrying provider mechanism.
- Removed the now-redundant manual wiring from the sample feature modules and
  shared aggregator; updated docs to reflect auto-wiring.
- TestKit coverage: per-project-type wiring fixtures with a minimal runtime
  stub assert generated symbols compile with no manual wiring.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- Remove the dead optional `producer` parameter from the KMP/JVM wiring
  helpers and rewrite the stale KDoc that described the obsolete pure-layout
  workaround removed by the @OutputDirectory refactor.
- Narrow the helper parameter from Provider<out Any> to Provider<out Directory>.
- Warn (instead of silently no-op) when an AGP module has no Kotlin `main`
  source set, pointing the developer at the missing Kotlin Android plugin.
- Pass --no-build-cache in the wiring TestKit runs so a cached compile cannot
  mask broken wiring.
- Fix the GeneratedSourceWiringTest KDoc and CLAUDE.md to reflect the dedicated
  generated/featured/registry directory.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@kirich1409 kirich1409 force-pushed the feat/249-autowire-generated-sources branch from 47395a6 to 7246b89 Compare June 13, 2026 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request gradle-plugin featured-gradle-plugin work sample Sample app status:in-progress Issue status: status:in-progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant