fix: refactor project output layout into shared projectlayout domain typ - #449
Merged
cdsap merged 1 commit intoSep 6, 2026
Merged
Conversation
cdsap
deleted the
issue/448-hermes-refactor-project-output-layout-into-a1
branch
September 6, 2026 19:18
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
Filesystem layout rules for Language (KTS, GROOVY, BOTH) are duplicated across
cli/src/main/kotlin/io/github/cdsap/projectgenerator/cli/GenerateProjectRequest.kt(resolveProjectRootPath) andproject-generator/src/main/kotlin/io/github/cdsap/projectgenerator/ProjectGenerator.kt(getProjectLanguageAttributes). The CLI picks a root path and the generator expands it intoLanguageAttributes, but both encode the same policy with no single source of truth.Why this matters
This is domain policy, not CLI or I/O detail. If one side changes (for example how
--output-dirinteracts withLanguage.BOTH) without the other, the CLI can report one location while files are written elsewhere. Tests are split acrossGenerateProjectsCliTestandProjectGeneratorTest, so regressions are easy to miss.Proposed change
Add
ProjectLayoutinproject-generator/src/main/kotlin/io/github/cdsap/projectgenerator/model/with two pure functions:defaultRootPath(outputDir, language, projectName)(replacingresolveProjectRootPath) andlanguageAttributes(rootPath, language)(replacinggetProjectLanguageAttributes). UpdateGenerateProjectRequest.resolveandProjectGenerator.write()to delegate to it. Add focused unit tests inproject-generatorfor all language/output-dir combinations.Notes
In clean-architecture terms, output layout is a domain policy consumed by the CLI adapter and the generation use case. Centralizing it in
model/keeps infrastructure (Clikt,Filewriters) separate from the rule of where each language variant lives on disk, and gives library callers the same layout contract the CLI uses.Fixes #448
Changes
cli/src/main/kotlin/io/github/cdsap/projectgenerator/cli/GenerateProjectRequest.ktcli/src/test/kotlin/io/github/cdsap/projectgenerator/cli/GenerateProjectsCliTest.ktproject-generator/src/main/kotlin/io/github/cdsap/projectgenerator/ProjectGenerator.ktproject-generator/src/main/kotlin/io/github/cdsap/projectgenerator/model/ProjectLayout.ktproject-generator/src/test/kotlin/io/github/cdsap/projectgenerator/model/ProjectLayoutTest.ktVerification
./gradlew :project-generator:unitTest./gradlew :cli:test./gradlew ktlintCheck