Skip to content

Commit

Permalink
XIVY-9730 Load jvm-module.options from bin/jvm-module.options with ba…
Browse files Browse the repository at this point in the history
…ckward compatiblity support
  • Loading branch information
alexsuter committed Jun 14, 2024
1 parent 4ac678d commit c5b592c
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/main/java/ch/ivyteam/ivy/maven/engine/EngineModuleHints.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.nio.file.Files;
import java.util.List;
import java.util.stream.Collectors;

import org.apache.commons.exec.CommandLine;
import org.apache.commons.io.FileUtils;
import org.apache.maven.plugin.logging.Log;

public class EngineModuleHints {
Expand All @@ -22,20 +20,25 @@ public static String loadFromJvmOptionsFile(File identifyAndGetEngineDirectory,
}

private static List<String> loadJvmOptions(File engineDir, Log log) {
File jvmOptionsFile = new File(engineDir, "configuration/jvm-module.options");
if (!jvmOptionsFile.exists()) {
log.warn("Couldn't load jvm module options from '" + jvmOptionsFile + "' file.");
return Collections.emptyList();
var jvmOptionsFile = engineDir.toPath().resolve("bin").resolve("jvm-module.options");
if (!Files.exists(jvmOptionsFile)) {
// Fallback: It was placed in another place in Axon Ivy Engine before 11.4.0
log.info("File does not exist '" + jvmOptionsFile + "'");
jvmOptionsFile = engineDir.toPath().resolve("configuration").resolve("jvm-module.options");
if (!Files.exists(jvmOptionsFile)) {
log.warn("Couldn't load jvm module options from '" + jvmOptionsFile + "' file.");
return List.of();
}
}

try {
return FileUtils.readLines(jvmOptionsFile, StandardCharsets.UTF_8).stream()
return Files.readAllLines(jvmOptionsFile).stream()
.filter(line -> !line.isBlank())
.filter(line -> !line.matches("^\\s*#.*$"))
.collect(Collectors.toList());
} catch (IOException ex) {
log.warn("Couldn't read the jvm module options from '" + jvmOptionsFile + "' file.", ex);
return Collections.emptyList();
return List.of();
}
}
}
}

0 comments on commit c5b592c

Please sign in to comment.