fix: refactor generated module paths to a shared layout helper - #427
Merged
cdsap merged 1 commit intoAug 28, 2026
Merged
Conversation
cdsap
deleted the
issue/426-hermes-refactor-generated-module-paths-to-a-a1
branch
August 28, 2026 20:34
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
Generated module filesystem paths are assembled independently in several generation/writer classes: ModulesWriter.kt:71-83 creates source/test directories, ResourceGenerator.kt:34-39 and 74-85 creates resource/manifest paths, ClassGeneratorAndroid.kt:752-760 writes class paths, and TestGeneratorAndroid.kt:25-33 writes test paths. Each repeats layer/module/package lookup plus string-concatenated source-set paths.
Why this matters
Android KMP source-set behavior already depends on module type and kotlinMultiplatformLibrary. Keeping that path policy duplicated makes future layout changes easy to apply inconsistently, especially between pre-created directories, generated classes, tests, resources, and manifests.
Proposed change
Introduce one small core/project-generator helper, for example GeneratedModuleLayout, that takes projectName, ProjectGraph or module metadata, and kotlinMultiplatformLibrary, then exposes File builders for main Kotlin package, test Kotlin package, resources layout/values, and manifest directory. Migrate the Android generation call sites to use it without changing generated paths or file contents.
Notes
Clean architecture lens: this keeps generated-project layout policy in one domain-level helper instead of scattering infrastructure path strings through content generators and writers.
Fixes #426
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/ModulesWriter.ktproject-generator/src/test/kotlin/io/github/cdsap/projectgenerator/generator/GeneratedModuleLayoutTest.ktVerification
./gradlew :project-generator:unitTest./gradlew :cli:test./gradlew ktlintCheck