Skip to content

Refactor module layout to use immutable name maps #493

Description

@cdsap

Problem

GeneratedModuleLayout directly reads mutable global NameMappings, while ProjectNameMappingFactory already produces immutable ProjectNameMaps and ProjectWriter receives those maps explicitly.

Why This Matters

Generation and tests depend on process-wide mutable state, which can leak between runs, complicate parallel execution, and make layout behavior harder to test with custom mappings.

Proposed Change

Thread ProjectNameMaps through the module-writing boundary and have GeneratedModuleLayout use the supplied maps instead of importing NameMappings. Preserve existing fallback names and generated paths.

Files

  • project-generator/src/main/kotlin/io/github/cdsap/projectgenerator/generator/GeneratedModuleLayout.kt
  • project-generator/src/main/kotlin/io/github/cdsap/projectgenerator/writer/ModulesWriter.kt
  • project-generator/src/main/kotlin/io/github/cdsap/projectgenerator/writer/ProjectWriter.kt
  • project-generator/src/main/kotlin/io/github/cdsap/projectgenerator/ProjectGenerator.kt

Constraints

  • Preserve behavior.
  • Preserve generated directory and package names.
  • Keep the existing ProjectNameMaps fallback behavior.
  • Do not redesign unrelated generators or remove the public generation API.
  • Keep this as a small refactor; do not perform a broad architecture migration.
  • Do not change public APIs unless the issue explicitly requires it.

Acceptance Criteria

  • Configured unit tests pass.
  • Generated Android and JVM projects use the same paths as before.
  • GeneratedModuleLayout no longer reads NameMappings global state.
  • ktlintCheck passes.
  • Existing behavior is preserved.

Validation

  • ./gradlew :project-generator:unitTest
  • ./gradlew :cli:test
  • ./gradlew ktlintCheck

Notes

ProjectNameMaps becomes the domain value passed through the generation boundary, while NameMappings remains isolated as legacy compatibility state during this incremental step.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    architectureArchitecture, module boundaries, or dependency directionquality-codeGenerated by Hermes Quality Code for small architecture refactorsrefactorCode change that preserves behavior while improving structure

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions