diff --git a/cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/CobiGenFactory.java b/cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/CobiGenFactory.java index edcb1b04e..4c9d06eb2 100644 --- a/cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/CobiGenFactory.java +++ b/cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/CobiGenFactory.java @@ -104,11 +104,14 @@ public static CobiGen create(URI configFileOrFolder, boolean allowMonolithicConf // install Template Sets defined in .properties file if (configurationHolder.isTemplateSetConfiguration()) { ConfigurationProperties config = configurationHolder.getConfigurationProperties(); - Path templatesLocation = configurationHolder.getConfigurationPath(); - List downloadUrls = ArtifactRetriever.retrieveTemplateSetJarDownloadURLs(config.getGroupIds(), - config.getMavenCoordinates()); - for (String downloadUrl : downloadUrls) { - TemplatesJarUtil.downloadJarFromURL(downloadUrl, templatesLocation); + // if installed template sets property was not empty, install found template sets + if (!config.getTemplateSetsInstalled().isEmpty()) { + Path templatesLocation = configurationHolder.getConfigurationPath(); + List downloadUrls = ArtifactRetriever.retrieveTemplateSetJarDownloadURLs(config.getGroupIds(), + config.getTemplateSetsInstalled()); + for (String downloadUrl : downloadUrls) { + TemplatesJarUtil.downloadJarFromURL(downloadUrl, templatesLocation); + } } } return createBean; diff --git a/cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/config/ConfigurationProperties.java b/cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/config/ConfigurationProperties.java index f909ffe96..28c3a2bf6 100644 --- a/cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/config/ConfigurationProperties.java +++ b/cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/config/ConfigurationProperties.java @@ -5,8 +5,8 @@ import com.devonfw.cobigen.api.util.MavenCoordinate; /** - * Data wrapper for configuration Properties. The properties are groupIds, hideTemplates and allowSnapshots - * + * Data wrapper for configuration Properties. The properties are groupIds, hideTemplates, allowSnapshots and + * templateSetsInstalled */ public class ConfigurationProperties { @@ -16,27 +16,27 @@ public class ConfigurationProperties { /** allow snapshots of template-sets */ private boolean allowSnapshots; - /** List of mavenCoordinates for the template sets that should be installed at cobigen startup */ - private List templatesInstalled; + /** List of mavenCoordinates for the template sets that should be installed at CobiGen startup */ + private List templateSetsInstalled; /** variable to hide very specific template sets or versions of template sets */ - private List hideTemplates; + private List hideTemplateSets; /** - * The constructor. load properties from a given source + * The constructor. Loads properties from a given source * * @param groupIds groupID from key template-sets.groupIds * @param allowSnapshots from key template-sets.allow-snapshot * @param hideTemplates from key template-set.hide - * @param mavenCoordinates list of mavenCoordinate that define the templates that should be installed + * @param templateSetsInstalled list of mavenCoordinate that define the templates sets that should be installed */ public ConfigurationProperties(List groupIds, boolean allowSnapshots, List hideTemplates, - List mavenCoordinates) { + List templateSetsInstalled) { this.groupIds = groupIds; this.allowSnapshots = allowSnapshots; - this.hideTemplates = hideTemplates; - this.templatesInstalled = mavenCoordinates; + this.hideTemplateSets = hideTemplates; + this.templateSetsInstalled = templateSetsInstalled; } /** @@ -82,21 +82,21 @@ public void setAllowSnapshots(boolean allowSnapshots) { /** * Returns a list of the saved templates to be hidden * - * @return hideTemplates + * @return hideTemplateSets */ - public List getHideTemplates() { + public List getHideTemplateSets() { - return this.hideTemplates; + return this.hideTemplateSets; } /** * Sets a list of the HideTemplate from a source * - * @param hideTemplates new value of {@link #gethideTemplates}. + * @param hideTemplateSets new value of {@link #gethideTemplateSets}. */ - public void setHideTemplates(List hideTemplates) { + public void setHideTemplateSets(List hideTemplateSets) { - this.hideTemplates = hideTemplates; + this.hideTemplateSets = hideTemplateSets; } /** @@ -104,19 +104,19 @@ public void setHideTemplates(List hideTemplates) { * * @return maven coordinates */ - public List getMavenCoordinates() { + public List getTemplateSetsInstalled() { - return this.templatesInstalled; + return this.templateSetsInstalled; } /** - * Set a list of templates that should be installed at startup + * Set a list of template sets that should be installed at startup * - * @param mavenCoordinates new value of {@link #getmavenCoordinates}. + * @param templateSetsInstalled new value of {@link #getTemplateSetsInstalled}. */ - public void setMavenCoordinates(List mavenCoordinates) { + public void setTemplateSetsInstalled(List templateSetsInstalled) { - this.templatesInstalled = mavenCoordinates; + this.templateSetsInstalled = templateSetsInstalled; } } diff --git a/cobigen/cobigen-core/src/test/java/com/devonfw/cobigen/unittest/config/ConfigurationFinderTest.java b/cobigen/cobigen-core/src/test/java/com/devonfw/cobigen/unittest/config/ConfigurationFinderTest.java index 19dc46438..9aa926693 100644 --- a/cobigen/cobigen-core/src/test/java/com/devonfw/cobigen/unittest/config/ConfigurationFinderTest.java +++ b/cobigen/cobigen-core/src/test/java/com/devonfw/cobigen/unittest/config/ConfigurationFinderTest.java @@ -47,7 +47,7 @@ public void emptyConfigurationTest() throws IOException { ConfigurationProperties conf = ConfigurationFinder.retrieveCobiGenProperties(emptyConfiguration); assertThat(conf.getGroupIds()).contains(ConfigurationConstants.CONFIG_PROPERTY_TEMPLATE_SETS_DEFAULT_GROUPID); - assertThat(conf.getHideTemplates()).isEmpty(); + assertThat(conf.getHideTemplateSets()).isEmpty(); assertThat(conf.isAllowSnapshots()).isFalse(); } @@ -67,9 +67,9 @@ public void validConfigurationTest() throws IOException { assertThat(conf.getGroupIds()).containsSequence("devonfw-cobigen-bla", "abcd", "blablob", ConfigurationConstants.CONFIG_PROPERTY_TEMPLATE_SETS_DEFAULT_GROUPID); assertThat(conf.isAllowSnapshots()).isTrue(); - assertThat(conf.getHideTemplates().get(0).getArtifactId().equals("com.devonfw")); - assertThat(conf.getHideTemplates().get(0).getGroupId().equals("test-artifact")); - assertThat(conf.getHideTemplates().get(0).getVersion().equals("3.2.1-SNAPSHOT")); + assertThat(conf.getHideTemplateSets().get(0).getArtifactId().equals("com.devonfw")); + assertThat(conf.getHideTemplateSets().get(0).getGroupId().equals("test-artifact")); + assertThat(conf.getHideTemplateSets().get(0).getVersion().equals("3.2.1-SNAPSHOT")); } /** @@ -85,8 +85,8 @@ public void invalidInputConfigurationTest() throws IOException { .get("src/test/resources/testdata/unittest/config/properties/invalidConfigProperties/config.properties"); ConfigurationProperties conf = ConfigurationFinder.retrieveCobiGenProperties(validConfiguration); - assertTrue(conf.getHideTemplates().isEmpty()); - assertTrue(conf.getMavenCoordinates().isEmpty()); + assertTrue(conf.getHideTemplateSets().isEmpty()); + assertTrue(conf.getTemplateSetsInstalled().isEmpty()); } /** @@ -103,7 +103,7 @@ public void invalidPathTest() throws IOException { ConfigurationProperties conf = ConfigurationFinder.retrieveCobiGenProperties(invalidPath); assertThat(conf.getGroupIds()).contains(ConfigurationConstants.CONFIG_PROPERTY_TEMPLATE_SETS_DEFAULT_GROUPID); - assertThat(conf.getHideTemplates()).isEmpty(); + assertThat(conf.getHideTemplateSets()).isEmpty(); assertThat(conf.isAllowSnapshots()).isFalse(); }