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

Optimize CobiGen startup process and detection of a monolithic configuration #1664

Open
EduardKrieger opened this issue Mar 31, 2023 · 0 comments

Comments

@EduardKrieger
Copy link
Contributor

The detection of a monolithic configuration occurs late in the startup process and takes place, after a CobiGen object is created, in the configurationHolder by a simple query whether the passed path of the configuration contains a template sets. This can be checked earlier and the DeprecatedMonolithicConfigurationException can be thrown faster and would improve the startup of Cobigen.

Throw of the Exception:

if (!allowMonolithicConfiguration && !configurationHolder.isTemplateSetConfiguration()) {
throw new DeprecatedMonolithicConfigurationException(Paths.get(configFileOrFolder));

The check for a template-sets configuration

public boolean isTemplateSetConfiguration() {
// TODO: Replace with a better logic for template set detection later f.e. groupid, see: https://github.com/devonfw/cobigen/issues/1660
if (this.configurationPath.toUri().getScheme().equals("jar")
|| !this.configurationPath.getFileName().toString().equals(ConfigurationConstants.TEMPLATE_SETS_FOLDER)) {
return false;
}
return true;
}

I would suggest implementing the new check right before registerPlugins():

/**
* Registers CobiGen plug-ins and instantiates CobiGen
*
* @param templatesProject the templates project or jar
* @param allowMonolithicConfiguration ignores deprecated monolithic template folder structure and if found does not
* throw a DeprecatedMonolithicConfigurationException
* @return object of CobiGen
*/
public static CobiGen initializeCobiGen(Path templatesProject, boolean allowMonolithicConfiguration) {
registerPlugins();
if (templatesProject != null) {
return CobiGenFactory.create(templatesProject.toUri(), allowMonolithicConfiguration);
} else {
return CobiGenFactory.create(allowMonolithicConfiguration);
}
}

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

No branches or pull requests

1 participant