Skip to content

Commit

Permalink
Fix Liberty version comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
cherylking committed May 4, 2024
1 parent 5a19012 commit 560a9c0
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/main/java/io/openliberty/tools/ant/jsp/CompileJSPs.java
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,23 @@ private ServerTask createServerTask(File usrDir) {
return server;
}

private boolean isVersion24xxOrLater(String version) {
boolean flag = false;

if (version != null && version.contains(".")) {
String majorVersion = version.substring(0,version.indexOf("."));
try {
Integer majorVersionInt = new Integer(majorVersion);
if (majorVersionInt.intValue() >= 24) {
flag = true;
}
} catch (NumberFormatException e) {
}
}

return flag;
}

private String determineSourceAttribute(File serverDir) {
String sourceAttrToUse = "jdkSourceLevel";
File f = new File(wlpHome,"lib/versions/openliberty.properties");
Expand All @@ -377,7 +394,7 @@ private String determineSourceAttribute(File serverDir) {

libertyProductProperties.load(input);
String version = libertyProductProperties.getProperty("com.ibm.websphere.productVersion");
if (version != null && version.startsWith("24.")) {
if (isVersion24xxOrLater(version)) {
if (useJdkSourceLevel && source.equals("18")) {
// change source 18 to 8 and use javaSourceLevel instead
source = "8";
Expand Down

0 comments on commit 560a9c0

Please sign in to comment.