Skip to content

Commit

Permalink
Close #434
Browse files Browse the repository at this point in the history
* Try and find a more recent JRE/JDK version in case the Manifest found version is not available (best guess - trying only the next major version)
  • Loading branch information
anthonydahanne committed Nov 12, 2024
1 parent 0e9aca2 commit e6513ec
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions jvm_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,13 @@ func retrieveNextAvailableJavaVersionIfMavenVersionNotAvailable(dr libpak.Depend
if libpak.IsNoValidDependencies(jdkErr) && libpak.IsNoValidDependencies(jreErr) {
// the buildpack does not provide the wanted JDK or JRE version - let's check if we can choose a more recent version
mavenJavaMajorVersionAsInt, _ := strconv.ParseInt(*mavenJavaMajorVersion, 10, 64)
versionToEvaluate := mavenJavaMajorVersionAsInt + 1
for versionToEvaluate <= mavenJavaMajorVersionAsInt+5 {
_, jdkErr := dr.Resolve("jdk", strconv.FormatInt(versionToEvaluate, 10))
_, jreErr := dr.Resolve("jre", strconv.FormatInt(versionToEvaluate, 10))
if libpak.IsNoValidDependencies(jdkErr) && libpak.IsNoValidDependencies(jreErr) {
versionToEvaluate = versionToEvaluate + 1
} else {
*mavenJavaMajorVersion = strconv.FormatInt(versionToEvaluate, 10)
break
}
nextVersionToEvaluate := mavenJavaMajorVersionAsInt + 1
_, jdkErr := dr.Resolve("jdk", strconv.FormatInt(nextVersionToEvaluate, 10))
_, jreErr := dr.Resolve("jre", strconv.FormatInt(nextVersionToEvaluate, 10))
if libpak.IsNoValidDependencies(jdkErr) && libpak.IsNoValidDependencies(jreErr) {
// we tried with the next major version, still no Java candidate, we are done trying.
} else {
*mavenJavaMajorVersion = strconv.FormatInt(nextVersionToEvaluate, 10)
}
}
}
Expand Down

0 comments on commit e6513ec

Please sign in to comment.