fix: refactor module layout generation to use explicit project name maps - #486
Merged
cdsap merged 1 commit intoSep 22, 2026
Merged
Conversation
cdsap
deleted the
issue/485-hermes-refactor-module-layout-generation-to-a1
branch
September 22, 2026 20:40
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Problem
GeneratedModuleLayoutreads mutable global state fromNameMappings, whileProjectGeneratorconfigures that singleton before generation. This couples module layout infrastructure to process-wide state and is unsafe when generations overlap; seeProjectGenerator.kt,NameMappings.kt,ModulesWriter.kt, andGeneratedModuleLayout.kt.Why this matters
Concurrent or independently tested generations can observe another request's layer/module names, producing incorrect paths and package locations without a local failure.
Proposed change
Pass immutable
ProjectNameMapsfromProjectWriterthroughAndroidModulesWriter/JvmModulesWriterandModulesWriteintoGeneratedModuleLayout.of, replacing its directNameMappingslookups. Preserve the existing singleton for untouched generators as a follow-up boundary, without changing generated output.Notes
This is an incremental clean-architecture boundary: immutable naming context crosses into infrastructure explicitly, while the larger singleton migration remains outside this issue.
Fixes #485
Changes
project-generator/src/main/kotlin/io/github/cdsap/projectgenerator/generator/GeneratedModuleLayout.ktproject-generator/src/main/kotlin/io/github/cdsap/projectgenerator/generator/classes/ClassGeneratorAndroid.ktproject-generator/src/main/kotlin/io/github/cdsap/projectgenerator/generator/resources/ResourceGenerator.ktproject-generator/src/main/kotlin/io/github/cdsap/projectgenerator/generator/test/TestGeneratorAndroid.ktproject-generator/src/main/kotlin/io/github/cdsap/projectgenerator/writer/AndroidModulesWriter.ktproject-generator/src/main/kotlin/io/github/cdsap/projectgenerator/writer/JvmModulesWriter.ktproject-generator/src/main/kotlin/io/github/cdsap/projectgenerator/writer/ModulesWriter.ktproject-generator/src/main/kotlin/io/github/cdsap/projectgenerator/writer/ProjectWriter.ktproject-generator/src/test/kotlin/io/github/cdsap/projectgenerator/ProjectGeneratorTest.ktproject-generator/src/test/kotlin/io/github/cdsap/projectgenerator/generator/GeneratedModuleLayoutTest.ktproject-generator/src/test/kotlin/io/github/cdsap/projectgenerator/writer/ModulesWriterTest.ktVerification
./gradlew :project-generator:unitTest./gradlew :cli:test./gradlew ktlintCheck