fix: refactor projectwriter to receive immutable project name mappings - #471
Merged
cdsap merged 1 commit intoSep 16, 2026
Merged
Conversation
cdsap
deleted the
issue/470-hermes-refactor-projectwriter-to-receive-im-a1
branch
September 16, 2026 19:44
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
ProjectWriter reads layer and module names from the mutable global NameMappings singleton instead of receiving them as an explicit dependency. ProjectGenerator configures this global state before writing, while ProjectWriterTest mutates and restores it manually.
Why this matters
The writer's output depends on hidden process-wide state, which couples generation runs, complicates parallel execution, and makes unit tests order-sensitive. The repository already has ProjectNameMaps as an immutable value object.
Proposed change
Add a ProjectNameMaps parameter to ProjectWriter and use it when rendering settings.gradle files. Pass the maps created by ProjectNameMappingFactory from ProjectGenerator, and update ProjectWriter tests to provide explicit maps instead of mutating NameMappings.
Notes
ProjectNameMaps acts as a domain value object, while ProjectWriter is an output adapter. Making the mapping dependency explicit clarifies that boundary and improves testability without changing the wider generation architecture.
Fixes #470
Changes
project-generator/src/main/kotlin/io/github/cdsap/projectgenerator/ProjectGenerator.ktproject-generator/src/main/kotlin/io/github/cdsap/projectgenerator/writer/ProjectWriter.ktproject-generator/src/test/kotlin/io/github/cdsap/projectgenerator/generator/buildfiles/BuildFilesGeneratorAndroidTest.ktproject-generator/src/test/kotlin/io/github/cdsap/projectgenerator/generator/buildfiles/BuildFilesGeneratorJvmTest.ktproject-generator/src/test/kotlin/io/github/cdsap/projectgenerator/generator/test/TestGeneratorAndroidTest.ktproject-generator/src/test/kotlin/io/github/cdsap/projectgenerator/generator/test/TestGeneratorJvmTest.ktproject-generator/src/test/kotlin/io/github/cdsap/projectgenerator/writer/ProjectWriterTest.ktVerification
./gradlew :project-generator:unitTest./gradlew :cli:test./gradlew ktlintCheck