Skip to content

Commit ee67917

Browse files
SDK OS configurable
1 parent acc385c commit ee67917

File tree

7 files changed

+66
-2
lines changed

7 files changed

+66
-2
lines changed

examples/docker/src/aem/default/etc/aem.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,11 @@ vendor:
241241
# AEM License properties file
242242
license_file: "aem/home/lib/license.properties"
243243

244+
# AEM SDK source files
245+
sdk:
246+
# Controls which distribution of dispatcher is unpacked (auto|unix|windows)
247+
os: auto
248+
244249
# JDK used to: run AEM instances, build OSGi bundles, assemble AEM packages
245250
java:
246251
# Require following versions before e.g running AEM instances

pkg/cfg/defaults.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/wttech/aemc/pkg/common/fmtx"
88
"github.com/wttech/aemc/pkg/instance"
99
"github.com/wttech/aemc/pkg/pkg"
10+
"github.com/wttech/aemc/pkg/sdk"
1011
"time"
1112
)
1213

@@ -36,6 +37,8 @@ func (c *Config) setDefaults() {
3637
v.SetDefault("vendor.quickstart.dist_file", common.QuickstartDistFile)
3738
v.SetDefault("vendor.quickstart.license_file", common.QuickstartLicenseFile)
3839

40+
v.SetDefault("vendor.sdk.os", sdk.OSAuto)
41+
3942
v.SetDefault("vendor.java.home_dir", "")
4043
v.SetDefault("vendor.java.version_constraints", []string{"=> 1.8, < 1.9", "=> 11, < 12", ">= 17, < 18", "=> 21, < 22"})
4144
v.SetDefault("vendor.java.download.url", c.tplString("https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.25%2B9/OpenJDK11U-jdk_[[.Arch]]_[[.Os]]_hotspot_11.0.25_9.[[.ArchiveExt]]"))

pkg/project/app_classic/aem/default/etc/aem.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,11 @@ vendor:
243243
# AEM License properties file
244244
license_file: "aem/home/lib/license.properties"
245245

246+
# AEM SDK source files
247+
sdk:
248+
# Controls which distribution of dispatcher is unpacked (auto|unix|windows)
249+
os: auto
250+
246251
# JDK used to: run AEM instances, build OSGi bundles, assemble AEM packages
247252
java:
248253
# Require following versions before e.g running AEM instances

pkg/project/app_cloud/aem/default/etc/aem.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,11 @@ vendor:
243243
# AEM License properties file
244244
license_file: "aem/home/lib/license.properties"
245245

246+
# AEM SDK source files
247+
sdk:
248+
# Controls which distribution of dispatcher is unpacked (auto|unix|windows)
249+
os: auto
250+
246251
# JDK used to: run AEM instances, build OSGi bundles, assemble AEM packages
247252
java:
248253
# Require following versions before e.g running AEM instances

pkg/project/instance/aem/default/etc/aem.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,11 @@ vendor:
238238
# AEM License properties file
239239
license_file: "aem/home/lib/license.properties"
240240

241+
# AEM SDK source files
242+
sdk:
243+
# Controls which distribution of dispatcher is unpacked (auto|unix|windows)
244+
os: auto
245+
241246
# JDK used to: run AEM instances, build OSGi bundles, assemble AEM packages
242247
java:
243248
# Require following versions before e.g running AEM instances

pkg/sdk.go

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,31 @@ package pkg
22

33
import (
44
"fmt"
5+
"github.com/samber/lo"
56
log "github.com/sirupsen/logrus"
67
"github.com/wttech/aemc/pkg/common/execx"
78
"github.com/wttech/aemc/pkg/common/filex"
89
"github.com/wttech/aemc/pkg/common/osx"
910
"github.com/wttech/aemc/pkg/common/pathx"
11+
"github.com/wttech/aemc/pkg/sdk"
1012
"path/filepath"
13+
"strings"
1114
)
1215

1316
func NewSDK(vendorManager *VendorManager) *SDK {
14-
return &SDK{vendorManager: vendorManager}
17+
cv := vendorManager.aem.Config().Values()
18+
19+
return &SDK{
20+
vendorManager: vendorManager,
21+
22+
OS: cv.GetString("vendor.sdk.os"),
23+
}
1524
}
1625

1726
type SDK struct {
1827
vendorManager *VendorManager
28+
29+
OS string
1930
}
2031

2132
func (s SDK) Dir() string {
@@ -118,7 +129,12 @@ func (s SDK) findFile(pattern string) (string, error) {
118129
}
119130

120131
func (s SDK) unpackDispatcher() error {
121-
if osx.IsWindows() {
132+
os, err := s.determineOs()
133+
if err != nil {
134+
return err
135+
}
136+
137+
if os == sdk.OSWindows {
122138
zip, err := s.dispatcherToolsWindowsZip()
123139
if err != nil {
124140
return err
@@ -145,6 +161,20 @@ func (s SDK) unpackDispatcher() error {
145161
return nil
146162
}
147163

164+
func (s SDK) determineOs() (string, error) {
165+
os := s.OS
166+
if !lo.Contains(sdk.OsTypes(), os) {
167+
return "", fmt.Errorf("unsupported SDK OS type '%s', supported types are: %s", os, strings.Join(sdk.OsTypes(), ", "))
168+
}
169+
if os != sdk.OSAuto {
170+
return os, nil
171+
}
172+
if osx.IsWindows() {
173+
return sdk.OSWindows, nil
174+
}
175+
return sdk.OSUnix, nil
176+
}
177+
148178
func (s SDK) Destroy() error {
149179
return pathx.Delete(s.Dir())
150180
}

pkg/sdk/constants.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package sdk
2+
3+
const (
4+
OSAuto = "auto"
5+
OSUnix = "unix"
6+
OSWindows = "windows"
7+
)
8+
9+
func OsTypes() []string {
10+
return []string{OSAuto, OSUnix, OSWindows}
11+
}

0 commit comments

Comments
 (0)