[core] Add filesDir config option for directory-based template discovery#23884
Draft
aegeiger wants to merge 1 commit into
Draft
[core] Add filesDir config option for directory-based template discovery#23884aegeiger wants to merge 1 commit into
aegeiger wants to merge 1 commit into
Conversation
Add a new `filesDir` config option that allows users to point to a directory of additional template files instead of listing each one individually in the `files` map. Subdirectory names are automatically mapped to template types (api/, model/, apiDocs/, etc.). This is a natural extension of the existing `files` feature introduced in v5.0.0, reducing config verbosity when many additional templates are needed. When both `files` and `filesDir` are specified, explicit `files` entries take precedence over auto-discovered ones.
Author
|
This PR is complementary to the issue - if maintainers will requests changes on the issue, I'll update this PR. |
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.
Fixes #23877
Adds a new
filesDirconfig option that allows users to point to a directory of additional template files instead of listing each one individually in thefilesmap. Subdirectory names automatically determine the template type.Example
How to validate
.mustachetemplate filesfilesDir: path/to/dirto your generator config YAMLfilesentries take precedence when both are specifiedfilesDirworks when pointing at a symlink to a directoryFiles changed
DynamicSettings.javafilesDirfield, directory scanning logic (follows symlinks), merge with existingfilesentriesDynamicSettingsTest.javadocs/customization.mdDesign decisions
api/,model/,apiDocs/, etc.) map toTemplateFileTypevalues (case-insensitive). Unrecognized directory names default toSupportingFileswith the path used as the output folder.files: when both are specified, explicitfilesentries take precedence over auto-discovered ones.filesDiritself can be a symlink, and symlinks within the tree are followed. No cycle detection is provided — this is documented.DynamicSettings.java. No changes toCodegenConfigurator,DefaultGenerator,TemplateDefinition,TemplateFileType, CLI, or any generator — the downstream pipeline already works withList<TemplateDefinition>generically.filesDiris optional; existing behavior is unchanged.PR checklist
filesDir) that is not used by any existing generator config.master(upcoming7.x.0minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)"fixes #123"present in the PR description)Fixes [REQ] Add filesDir config option for directory-based template discovery #23877
N/A — this is a core/config change, not language-specific.
Summary by cubic
Adds a new
filesDirconfig option for directory-based template discovery to reduce config noise. Subfolders map to template types, and explicitfilesentries still win on conflicts.filesDirscans a directory (follows symlinks) and auto-adds templates.api/,model/,apiDocs/,modelDocs/,apiTests/,modelTests/,supportingFiles/.SupportingFiles; unknown subfolders becomeSupportingFileswith the folder path preserved..mustachesuffix is stripped from the destination filename.files; explicitfilesentries take precedence. Backward compatible.Written for commit 94f7a0b. Summary will update on new commits. Review in cubic