Skip to content

Commit f1842b2

Browse files
committed
Fixed issue.
1 parent 2c7e128 commit f1842b2

1 file changed

Lines changed: 26 additions & 21 deletions

File tree

src/main/java/org/mangorage/mangobotgradle/tasks/RunInstallerAndBootTask.java

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,34 +26,39 @@ public RunInstallerAndBootTask(RunConfig runConfig) {
2626

2727
setWorkingDir(getProject().file("build/run/"));
2828

29-
Path plugins = getProject().getProjectDir().toPath().resolve("build/run/plugins");
30-
StringBuilder builder = new StringBuilder();
29+
Path pluginsPath = getProject()
30+
.getProjectDir()
31+
.toPath()
32+
.resolve("build/run/plugins");
3133

32-
for (File file : plugins.toFile().listFiles()) {
33-
System.out.println(file.getName());
34-
if (!file.isDirectory() && file.getName().contains(".jar"))
35-
builder.append(file.toPath().toAbsolutePath()).append(";");
36-
}
34+
List<String> pluginJars = new ArrayList<>();
3735

38-
String args = builder.substring(0, builder.length() - 1);
39-
var finalArgs = List.of("-manualJar", args);
36+
File pluginsDir = pluginsPath.toFile();
37+
if (pluginsDir.exists() && pluginsDir.isDirectory()) {
38+
File[] files = pluginsDir.listFiles();
39+
if (files != null) {
40+
for (File file : files) {
41+
if (file.isFile() && file.getName().endsWith(".jar")) {
42+
pluginJars.add(file.getAbsolutePath());
43+
}
44+
}
45+
}
46+
}
4047

41-
List<String> argsForProgram = new ArrayList<>();
42-
argsForProgram.addAll(runConfig.getArgs());
48+
List<String> argsForProgram = new ArrayList<>(runConfig.getArgs());
4349
argsForProgram.add("-launch");
44-
argsForProgram.add("-manualJar");
45-
argsForProgram.add(args);
46-
setArgs(argsForProgram);
4750

48-
// Create your module path from the config
49-
FileCollection modulePath = getProject().getConfigurations().getByName("installer");
51+
if (!pluginJars.isEmpty()) {
52+
String jarsArg = String.join(";", pluginJars);
53+
argsForProgram.add("-manualJar");
54+
argsForProgram.add(jarsArg);
55+
}
5056

57+
setArgs(argsForProgram);
5158

52-
setClasspath(modulePath); // EMPTY CLASSPATH, this is MODULE mode
53-
getMainClass().set("org.mangorage.installer.Installer");
54-
getMainModule().set("org.mangorage.installer");
55-
getModularity().getInferModulePath().set(true);
59+
FileCollection modulePath =
60+
getProject().getConfigurations().getByName("installer");
5661

57-
setJvmArgs(List.of("--add-modules", "java.scripting", "--add-modules", "java.instrument", "--add-modules", "java.sql", "--add-modules", "jdk.unsupported"));
62+
setClasspath(modulePath); // EMPTY CLASSPATH, this is MODULE mode
5863
}
5964
}

0 commit comments

Comments
 (0)