Skip to content

Commit c6fac4e

Browse files
Allow only supported Java versions for AEM
1 parent b357ea4 commit c6fac4e

File tree

7 files changed

+18
-15
lines changed

7 files changed

+18
-15
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ instance:
421421

422422
java:
423423
# Require following versions before e.g running AEM instances
424-
version_constraints: ">= 11, < 12"
424+
version_constraints: [">= 1.8, < 1.9", ">= 11, < 12", ">= 17, < 18", ">= 21, < 22"]
425425

426426
# Pre-installed local JDK dir
427427
# a) keep it empty to download open source Java automatically for current OS and architecture
@@ -478,7 +478,7 @@ vendor:
478478
# JDK used to: run AEM instances, build OSGi bundles, assemble AEM packages
479479
java:
480480
# Require following versions before e.g running AEM instances
481-
version_constraints: ">= 11, < 12"
481+
version_constraints: [">= 1.8, < 1.9", ">= 11, < 12", ">= 17, < 18", ">= 21, < 22"]
482482

483483
# Pre-installed local JDK dir
484484
# a) keep it empty to download open source Java automatically for current OS and architecture

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ vendor:
242242
# JDK used to: run AEM instances, build OSGi bundles, assemble AEM packages
243243
java:
244244
# Require following versions before e.g running AEM instances
245-
version_constraints: ">= 11, < 12"
245+
version_constraints: [">= 1.8, < 1.9", ">= 11, < 12", ">= 17, < 18", ">= 21, < 22"]
246246

247247
# Pre-installed local JDK dir
248248
# a) keep it empty to download open source Java automatically for current OS and architecture

pkg/cfg/defaults.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func (c *Config) setDefaults() {
3636
v.SetDefault("vendor.quickstart.license_file", common.QuickstartLicenseFile)
3737

3838
v.SetDefault("vendor.java.home_dir", "")
39-
v.SetDefault("vendor.java.version_constraints", ">= 11, < 12")
39+
v.SetDefault("vendor.java.version_constraints", []string{"=> 1.8, < 1.9", "=> 11, < 12", ">= 17, < 18", "=> 21, < 22"})
4040
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]]"))
4141
v.SetDefault("vendor.java.download.replacements", map[string]string{"darwin": "mac", "x86_64": "x64", "amd64": "x64", "386": "x86-32", "arm64": "x64", "aarch64": "x64"})
4242

pkg/java_manager.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type JavaManager struct {
2222
HomeDir string
2323
DownloadURL string
2424
DownloadURLReplacements map[string]string
25-
VersionConstraints string
25+
VersionConstraints []string
2626
}
2727

2828
func NewJavaManager(manager *VendorManager) *JavaManager {
@@ -34,7 +34,7 @@ func NewJavaManager(manager *VendorManager) *JavaManager {
3434
HomeDir: cv.GetString("vendor.java.home_dir"),
3535
DownloadURL: cv.GetString("vendor.java.download.url"),
3636
DownloadURLReplacements: cv.GetStringMapString("vendor.java.download.replacements"),
37-
VersionConstraints: cv.GetString("vendor.java.version_constraints"),
37+
VersionConstraints: cv.GetStringSlice("vendor.java.version_constraints"),
3838
}
3939
}
4040

@@ -119,16 +119,19 @@ func (jm *JavaManager) checkVersion() error {
119119
if err != nil {
120120
return err
121121
}
122-
if jm.VersionConstraints != "" {
123-
versionConstraints, err := version.NewConstraint(jm.VersionConstraints)
122+
if len(jm.VersionConstraints) == 0 {
123+
return nil
124+
}
125+
for _, vc := range jm.VersionConstraints {
126+
vco, err := version.NewConstraint(vc)
124127
if err != nil {
125-
return fmt.Errorf("java version constraint '%s' is invalid: %w", jm.VersionConstraints, err)
128+
return fmt.Errorf("java version constraint '%s' is invalid: %w", vc, err)
126129
}
127-
if !versionConstraints.Check(currentVersion) {
128-
return fmt.Errorf("java current version '%s' does not meet contraints '%s'", currentVersion, jm.VersionConstraints)
130+
if vco.Check(currentVersion) {
131+
return nil
129132
}
130133
}
131-
return nil
134+
return fmt.Errorf("java current version '%s' does not meet contraints '%s'", currentVersion, strings.Join(jm.VersionConstraints, " || "))
132135
}
133136

134137
func (jm *JavaManager) FindHomeDir() (string, error) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ vendor:
244244
# JDK used to: run AEM instances, build OSGi bundles, assemble AEM packages
245245
java:
246246
# Require following versions before e.g running AEM instances
247-
version_constraints: ">= 11, < 12"
247+
version_constraints: [">= 1.8, < 1.9", ">= 11, < 12", ">= 17, < 18", ">= 21, < 22"]
248248

249249
# Pre-installed local JDK dir
250250
# a) keep it empty to download open source Java automatically for current OS and architecture

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ vendor:
244244
# JDK used to: run AEM instances, build OSGi bundles, assemble AEM packages
245245
java:
246246
# Require following versions before e.g running AEM instances
247-
version_constraints: ">= 11, < 12"
247+
version_constraints: [">= 1.8, < 1.9", ">= 11, < 12", ">= 17, < 18", ">= 21, < 22"]
248248

249249
# Pre-installed local JDK dir
250250
# a) keep it empty to download open source Java automatically for current OS and architecture

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ vendor:
239239
# JDK used to: run AEM instances, build OSGi bundles, assemble AEM packages
240240
java:
241241
# Require following versions before e.g running AEM instances
242-
version_constraints: ">= 11, < 12"
242+
version_constraints: [">= 1.8, < 1.9", ">= 11, < 12", ">= 17, < 18", ">= 21, < 22"]
243243

244244
# Pre-installed local JDK dir
245245
# a) keep it empty to download open source Java automatically for current OS and architecture

0 commit comments

Comments
 (0)