Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REQ] Add an "overridesEmbedded" to Codegen Configs to Allow Extensions #5916

Open
sgarfinkel opened this issue Apr 13, 2020 · 0 comments
Open

Comments

@sgarfinkel
Copy link

sgarfinkel commented Apr 13, 2020

Is your feature request related to a problem? Please describe.

Currently, the CodegenConfigLoader just returns the first Config for a given name. This limits the ability for users to extend a provided code generator (the ServiceLoader as far as I can tell loads Services in arbitrary order).

Describe the solution you'd like

The name for this method could probably be more descriptive. The basic solution is this:

  1. Add a method Boolean overridesEmbedded() to the CodegenConfig.
  2. Add a method String overridesDir() to the CodegenConfig which defines the root of the set of templates to overlay on top of the embedded-dir.
  3. Update [AbstractGenerator.getFullTemplateFile] to check overridesDir after <template-folder>/*, but before <embedded-folder>/* which should avoid breaking changes for users of the templateDir commandline parameter.
  4. Add a implementations in DefaultCodegenConfig:
@Overrides
public Boolean overridesParent() {
	return false;
}

@Overrides
public String overridesDir() {
	return getTemplateDir();
}
  1. Update documentation to tell users who wish to customize existing Code Generators to override the overridesParent and overridesDir methods in their custom code generator.

Describe alternatives you've considered

An alternative way to do this would be to add a priority field instead. This would let users extend other overrides by setting their priority above the defined priority of their override.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant