Skip to content

Commit 07e7ad8

Browse files
fixed download by properties
made sure that template set jars only get downloaded when template-sets.installed was set renamed fields of ConfigurationProperties
1 parent 27dced6 commit 07e7ad8

File tree

3 files changed

+37
-34
lines changed

3 files changed

+37
-34
lines changed

cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/CobiGenFactory.java

+8-5
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,14 @@ public static CobiGen create(URI configFileOrFolder, boolean allowMonolithicConf
104104
// install Template Sets defined in .properties file
105105
if (configurationHolder.isTemplateSetConfiguration()) {
106106
ConfigurationProperties config = configurationHolder.getConfigurationProperties();
107-
Path templatesLocation = configurationHolder.getConfigurationPath();
108-
List<String> downloadUrls = ArtifactRetriever.retrieveTemplateSetJarDownloadURLs(config.getGroupIds(),
109-
config.getMavenCoordinates());
110-
for (String downloadUrl : downloadUrls) {
111-
TemplatesJarUtil.downloadJarFromURL(downloadUrl, templatesLocation);
107+
// if installed template sets property was not empty, install found template sets
108+
if (!config.getTemplateSetsInstalled().isEmpty()) {
109+
Path templatesLocation = configurationHolder.getConfigurationPath();
110+
List<String> downloadUrls = ArtifactRetriever.retrieveTemplateSetJarDownloadURLs(config.getGroupIds(),
111+
config.getTemplateSetsInstalled());
112+
for (String downloadUrl : downloadUrls) {
113+
TemplatesJarUtil.downloadJarFromURL(downloadUrl, templatesLocation);
114+
}
112115
}
113116
}
114117
return createBean;

cobigen/cobigen-core/src/main/java/com/devonfw/cobigen/impl/config/ConfigurationProperties.java

+22-22
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import com.devonfw.cobigen.api.util.MavenCoordinate;
66

77
/**
8-
* Data wrapper for configuration Properties. The properties are groupIds, hideTemplates and allowSnapshots
9-
*
8+
* Data wrapper for configuration Properties. The properties are groupIds, hideTemplates, allowSnapshots and
9+
* templateSetsInstalled
1010
*/
1111
public class ConfigurationProperties {
1212

@@ -16,27 +16,27 @@ public class ConfigurationProperties {
1616
/** allow snapshots of template-sets */
1717
private boolean allowSnapshots;
1818

19-
/** List of mavenCoordinates for the template sets that should be installed at cobigen startup */
20-
private List<MavenCoordinate> templatesInstalled;
19+
/** List of mavenCoordinates for the template sets that should be installed at CobiGen startup */
20+
private List<MavenCoordinate> templateSetsInstalled;
2121

2222
/** variable to hide very specific template sets or versions of template sets */
23-
private List<MavenCoordinate> hideTemplates;
23+
private List<MavenCoordinate> hideTemplateSets;
2424

2525
/**
26-
* The constructor. load properties from a given source
26+
* The constructor. Loads properties from a given source
2727
*
2828
* @param groupIds groupID from key template-sets.groupIds
2929
* @param allowSnapshots from key template-sets.allow-snapshot
3030
* @param hideTemplates from key template-set.hide
31-
* @param mavenCoordinates list of mavenCoordinate that define the templates that should be installed
31+
* @param templateSetsInstalled list of mavenCoordinate that define the templates sets that should be installed
3232
*/
3333
public ConfigurationProperties(List<String> groupIds, boolean allowSnapshots, List<MavenCoordinate> hideTemplates,
34-
List<MavenCoordinate> mavenCoordinates) {
34+
List<MavenCoordinate> templateSetsInstalled) {
3535

3636
this.groupIds = groupIds;
3737
this.allowSnapshots = allowSnapshots;
38-
this.hideTemplates = hideTemplates;
39-
this.templatesInstalled = mavenCoordinates;
38+
this.hideTemplateSets = hideTemplates;
39+
this.templateSetsInstalled = templateSetsInstalled;
4040
}
4141

4242
/**
@@ -82,41 +82,41 @@ public void setAllowSnapshots(boolean allowSnapshots) {
8282
/**
8383
* Returns a list of the saved templates to be hidden
8484
*
85-
* @return hideTemplates
85+
* @return hideTemplateSets
8686
*/
87-
public List<MavenCoordinate> getHideTemplates() {
87+
public List<MavenCoordinate> getHideTemplateSets() {
8888

89-
return this.hideTemplates;
89+
return this.hideTemplateSets;
9090
}
9191

9292
/**
9393
* Sets a list of the HideTemplate from a source
9494
*
95-
* @param hideTemplates new value of {@link #gethideTemplates}.
95+
* @param hideTemplateSets new value of {@link #gethideTemplateSets}.
9696
*/
97-
public void setHideTemplates(List<MavenCoordinate> hideTemplates) {
97+
public void setHideTemplateSets(List<MavenCoordinate> hideTemplateSets) {
9898

99-
this.hideTemplates = hideTemplates;
99+
this.hideTemplateSets = hideTemplateSets;
100100
}
101101

102102
/**
103103
* Returns a list of maven coordinates for the download of template sets
104104
*
105105
* @return maven coordinates
106106
*/
107-
public List<MavenCoordinate> getMavenCoordinates() {
107+
public List<MavenCoordinate> getTemplateSetsInstalled() {
108108

109-
return this.templatesInstalled;
109+
return this.templateSetsInstalled;
110110
}
111111

112112
/**
113-
* Set a list of templates that should be installed at startup
113+
* Set a list of template sets that should be installed at startup
114114
*
115-
* @param mavenCoordinates new value of {@link #getmavenCoordinates}.
115+
* @param templateSetsInstalled new value of {@link #getTemplateSetsInstalled}.
116116
*/
117-
public void setMavenCoordinates(List<MavenCoordinate> mavenCoordinates) {
117+
public void setTemplateSetsInstalled(List<MavenCoordinate> templateSetsInstalled) {
118118

119-
this.templatesInstalled = mavenCoordinates;
119+
this.templateSetsInstalled = templateSetsInstalled;
120120
}
121121

122122
}

cobigen/cobigen-core/src/test/java/com/devonfw/cobigen/unittest/config/ConfigurationFinderTest.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public void emptyConfigurationTest() throws IOException {
4747
ConfigurationProperties conf = ConfigurationFinder.retrieveCobiGenProperties(emptyConfiguration);
4848

4949
assertThat(conf.getGroupIds()).contains(ConfigurationConstants.CONFIG_PROPERTY_TEMPLATE_SETS_DEFAULT_GROUPID);
50-
assertThat(conf.getHideTemplates()).isEmpty();
50+
assertThat(conf.getHideTemplateSets()).isEmpty();
5151
assertThat(conf.isAllowSnapshots()).isFalse();
5252
}
5353

@@ -67,9 +67,9 @@ public void validConfigurationTest() throws IOException {
6767
assertThat(conf.getGroupIds()).containsSequence("devonfw-cobigen-bla", "abcd", "blablob",
6868
ConfigurationConstants.CONFIG_PROPERTY_TEMPLATE_SETS_DEFAULT_GROUPID);
6969
assertThat(conf.isAllowSnapshots()).isTrue();
70-
assertThat(conf.getHideTemplates().get(0).getArtifactId().equals("com.devonfw"));
71-
assertThat(conf.getHideTemplates().get(0).getGroupId().equals("test-artifact"));
72-
assertThat(conf.getHideTemplates().get(0).getVersion().equals("3.2.1-SNAPSHOT"));
70+
assertThat(conf.getHideTemplateSets().get(0).getArtifactId().equals("com.devonfw"));
71+
assertThat(conf.getHideTemplateSets().get(0).getGroupId().equals("test-artifact"));
72+
assertThat(conf.getHideTemplateSets().get(0).getVersion().equals("3.2.1-SNAPSHOT"));
7373
}
7474

7575
/**
@@ -85,8 +85,8 @@ public void invalidInputConfigurationTest() throws IOException {
8585
.get("src/test/resources/testdata/unittest/config/properties/invalidConfigProperties/config.properties");
8686
ConfigurationProperties conf = ConfigurationFinder.retrieveCobiGenProperties(validConfiguration);
8787

88-
assertTrue(conf.getHideTemplates().isEmpty());
89-
assertTrue(conf.getMavenCoordinates().isEmpty());
88+
assertTrue(conf.getHideTemplateSets().isEmpty());
89+
assertTrue(conf.getTemplateSetsInstalled().isEmpty());
9090
}
9191

9292
/**
@@ -103,7 +103,7 @@ public void invalidPathTest() throws IOException {
103103
ConfigurationProperties conf = ConfigurationFinder.retrieveCobiGenProperties(invalidPath);
104104

105105
assertThat(conf.getGroupIds()).contains(ConfigurationConstants.CONFIG_PROPERTY_TEMPLATE_SETS_DEFAULT_GROUPID);
106-
assertThat(conf.getHideTemplates()).isEmpty();
106+
assertThat(conf.getHideTemplateSets()).isEmpty();
107107
assertThat(conf.isAllowSnapshots()).isFalse();
108108
}
109109

0 commit comments

Comments
 (0)