Skip to content

Commit cf1ad85

Browse files
authored
Merge pull request #226 from galasa-dev/mcobbett-generated-project-builds-test-catalogs
generated project builds test catalogs
2 parents eb42dd6 + 724f17a commit cf1ad85

File tree

8 files changed

+119
-152
lines changed

8 files changed

+119
-152
lines changed

pkg/cmd/projectCreate.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package cmd
77

88
import (
99
"log"
10+
"sort"
1011
"strings"
1112

1213
"github.com/galasa-dev/cli/pkg/embedded"
@@ -269,7 +270,7 @@ func createParentFolderContents(
269270

270271
if useMaven {
271272
err = createParentFolderPom(fileGenerator, packageName, featureNames,
272-
isOBRProjectRequired, forceOverwrite)
273+
isOBRProjectRequired, forceOverwrite, isDevelopment)
273274
}
274275

275276
if err == nil {
@@ -331,6 +332,8 @@ func separateFeatureNamesFromCommaSeparatedList(featureNamesCommaSeparated strin
331332
}
332333
}
333334

335+
sort.Strings(featureNames)
336+
334337
return featureNames, err
335338
}
336339

@@ -341,6 +344,7 @@ func createParentFolderPom(
341344
featureNames []string,
342345
isOBRRequired bool,
343346
forceOverwrite bool,
347+
IsDevelopment bool,
344348
) error {
345349

346350
type ParentPomParameters struct {
@@ -352,6 +356,7 @@ func createParentFolderPom(
352356
IsOBRRequired bool
353357
ObrName string
354358
ChildModuleNames []string
359+
IsDevelopment bool
355360
}
356361

357362
galasaVersion, err := embedded.GetGalasaVersion()
@@ -363,6 +368,7 @@ func createParentFolderPom(
363368
IsOBRRequired: isOBRRequired,
364369
ObrName: packageName + ".obr",
365370
ChildModuleNames: make([]string, len(featureNames)),
371+
IsDevelopment: IsDevelopment,
366372
}
367373
// Populate the child module names
368374
for index, featureName := range featureNames {

pkg/cmd/projectCreate_test.go

+19
Original file line numberDiff line numberDiff line change
@@ -826,3 +826,22 @@ func TestProjectCreateAllFlagsReturnsNoOk(t *testing.T) {
826826
assert.Equal(t, cmd.Values().(*ProjectCreateCmdValues).useMaven, true)
827827
assert.Equal(t, cmd.Values().(*ProjectCreateCmdValues).useGradle, true)
828828
}
829+
830+
func TestSeparateFeatureNamesSortsTheResults(t *testing.T) {
831+
832+
features1, err := separateFeatureNamesFromCommaSeparatedList("payee,account")
833+
assert.Nil(t, err)
834+
assert.NotNil(t, features1)
835+
assert.Equal(t, 2, len(features1))
836+
assert.Equal(t, features1[0], "account")
837+
assert.Equal(t, features1[1], "payee")
838+
839+
// When we do the same thing in a different order...
840+
features2, err2 := separateFeatureNamesFromCommaSeparatedList("account,payee")
841+
// We should get the same results.
842+
assert.Nil(t, err2)
843+
assert.NotNil(t, features2)
844+
assert.Equal(t, 2, len(features2))
845+
assert.Equal(t, features2[0], "account")
846+
assert.Equal(t, features2[1], "payee")
847+
}

pkg/embedded/templates/projectCreate/parent-project/deploy.sh.template

-145
This file was deleted.

pkg/embedded/templates/projectCreate/parent-project/git-ignore.template

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,7 @@
1616

1717
# Ignore any built java artifacts
1818
**/*.class
19-
**/*.jar
19+
**/*.jar
20+
21+
# Ignore any temporary folder locally
22+
temp/

pkg/embedded/templates/projectCreate/parent-project/obr-project/build.gradle.template

+12-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
plugins {
33
id 'base'
44
id 'maven-publish'
5-
id 'dev.galasa.obr' version '0.15.0'
5+
id 'dev.galasa.obr' version '0.33.0'
6+
id 'dev.galasa.testcatalog' version '0.33.0'
67
}
78

89
// Set the variables which will control what the built OSGi bundle will be called
@@ -30,4 +31,14 @@ publishing {
3031
artifact obrFile
3132
}
3233
}
34+
}
35+
36+
// If we are deploying a test catalog using the galasa plugin,
37+
// directly to the ecosystem, then we can get the properties
38+
// we need from the system properties, passed on the command line using
39+
// -DGALASA_STREAM=xxx -DGALASA_BOOTSTRAP=xxx -DGALASA_TOKEN=xxx
40+
deployTestCatalog {
41+
bootstrap = System.getProperty("GALASA_BOOTSTRAP")
42+
stream = System.getProperty("GALASA_STREAM")
43+
token = System.getProperty("GALASA_TOKEN");
3344
}

pkg/embedded/templates/projectCreate/parent-project/pom.xml

+62-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
IsOBRRequired bool
1414
ObrName string
1515
ChildModuleNames []string
16+
IsDevelopment bool
1617
}
1718
*/}}
1819
<groupId>{{.Coordinates.GroupId}}</groupId>
@@ -57,6 +58,20 @@
5758
{{- end}}
5859
</modules>
5960

61+
<!--
62+
The following is used if you are publishing built artifacts into github's maven repository.
63+
Set it to something different if you are publishing to a different maven repository.
64+
65+
GITHUB_REPOSITORY is expected to hold a value of something like {github-org}/{repo-name}
66+
-->
67+
<distributionManagement>
68+
<repository>
69+
<id>github</id>
70+
<name>GitHub Packages</name>
71+
<url>https://maven.pkg.github.com/${GITHUB_REPOSITORY}</url>
72+
</repository>
73+
</distributionManagement>
74+
6075
<dependencyManagement>
6176
<dependencies>
6277
<dependency>
@@ -97,7 +112,7 @@
97112
<plugin>
98113
<groupId>org.apache.felix</groupId>
99114
<artifactId>maven-bundle-plugin</artifactId>
100-
<version>4.1.0</version>
115+
<version>5.1.1</version>
101116
</plugin>
102117
<plugin>
103118
<groupId>org.apache.maven.plugins</groupId>
@@ -107,7 +122,7 @@
107122
<plugin>
108123
<groupId>dev.galasa</groupId>
109124
<artifactId>galasa-maven-plugin</artifactId>
110-
<version>0.29.0</version>
125+
<version>0.33.0</version>
111126
</plugin>
112127
</plugins>
113128
</pluginManagement>
@@ -127,7 +142,7 @@
127142
<id>build-testcatalog</id>
128143
<phase>package</phase>
129144
<goals>
130-
<goal>bundletestcat</goal>
145+
<goal>bundletestcat</goal>
131146
</goals>
132147
</execution>
133148

@@ -146,4 +161,48 @@
146161
</plugins>
147162
</build>
148163

164+
<repositories>
165+
<repository>
166+
<id>maven.central</id>
167+
<url>https://repo.maven.apache.org/maven2/</url>
168+
</repository>
169+
{{if .IsDevelopment}}
170+
<!-- To use the bleeding edge version of galasa, use the development obr -->
171+
<repository>
172+
<id>galasa.repo</id>
173+
<url>https://development.galasa.dev/main/maven-repo/obr</url>
174+
</repository>
175+
{{- else }}
176+
<!-- To use the bleeding edge version of galasa, use the development obr -->
177+
<!--
178+
<repository>
179+
<id>galasa.repo</id>
180+
<url>https://development.galasa.dev/main/maven-repo/obr</url>
181+
</repository>
182+
-->
183+
{{- end }}
184+
</repositories>
185+
186+
<pluginRepositories>
187+
<pluginRepository>
188+
<id>maven.central</id>
189+
<url>https://repo.maven.apache.org/maven2/</url>
190+
</pluginRepository>
191+
{{if .IsDevelopment}}
192+
<!-- To use the bleeding edge version of galasa, use the development obr -->
193+
<pluginRepository>
194+
<id>galasa.repo</id>
195+
<url>https://development.galasa.dev/main/maven-repo/obr</url>
196+
</pluginRepository>
197+
{{- else }}
198+
<!-- To use the bleeding edge version of galasa, use the development obr -->
199+
<!--
200+
<pluginRepository>
201+
<id>galasa.repo</id>
202+
<url>https://development.galasa.dev/main/maven-repo/obr</url>
203+
</pluginRepository>
204+
-->
205+
{{- end }}
206+
</pluginRepositories>
207+
149208
</project>

pkg/embedded/templates/projectCreate/parent-project/settings.gradle.template

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
1+
{{/*
2+
This template expects the following parameters:
3+
4+
type ParentGradleParameters struct {
5+
Coordinates GradleCoordinates
6+
7+
IsOBRRequired bool
8+
ObrName string
9+
ChildModuleNames []string
10+
IsDevelopment bool
11+
}
12+
*/}}
13+
114

215
// Tell gradle where it should look to find the plugins and dependencies it needs to build.
316
pluginManagement {
417
repositories {
518
mavenLocal()
6-
mavenCentral()
719

820
{{- if .IsDevelopment }}
921
// To use the bleeding edge version of galasa's obr plugin, use the development obr
@@ -18,6 +30,7 @@ pluginManagement {
1830
{{- end }}
1931

2032
gradlePluginPortal()
33+
mavenCentral()
2134
}
2235
}
2336

0 commit comments

Comments
 (0)