feat(box): 增加插件目录参数处理
- 新增插件目录参数解析逻辑 - 实现插件目录的动态设置 - 优化参数预处理,提高代码可读性和可维护性
This commit is contained in:
@@ -14,6 +14,8 @@ import java.io.RandomAccessFile;
|
|||||||
import java.nio.channels.FileChannel;
|
import java.nio.channels.FileChannel;
|
||||||
import java.nio.channels.FileLock;
|
import java.nio.channels.FileLock;
|
||||||
import java.nio.channels.OverlappingFileLockException;
|
import java.nio.channels.OverlappingFileLockException;
|
||||||
|
import java.text.Format;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -40,19 +42,42 @@ public class Main {
|
|||||||
|
|
||||||
// 检查是否包含调试控制台参数
|
// 检查是否包含调试控制台参数
|
||||||
boolean debugWindowEnabled = false;
|
boolean debugWindowEnabled = false;
|
||||||
|
String pluginsDirectory = null;
|
||||||
|
|
||||||
|
// 新增:预处理参数,移除已处理的参数
|
||||||
|
List<String> remainingArgs = new ArrayList<>();
|
||||||
|
|
||||||
for (int i = 0; i < args.length; i++) {
|
for (int i = 0; i < args.length; i++) {
|
||||||
if (!releaseEnvironments && "-debugControlWindow-on".equals(args[i])) {
|
if (!releaseEnvironments && "-debugControlWindow-on".equals(args[i])) {
|
||||||
debugWindowEnabled = true;
|
debugWindowEnabled = true;
|
||||||
// 移除此参数避免干扰后续处理
|
// 不添加到剩余参数中
|
||||||
String[] newArgs = new String[args.length - 1];
|
continue;
|
||||||
System.arraycopy(args, 0, newArgs, 0, i);
|
|
||||||
System.arraycopy(args, i + 1, newArgs, i, args.length - i - 1);
|
|
||||||
args = newArgs;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 新增:解析pluginsDirectory参数
|
||||||
|
if (args[i].startsWith("pluginsDirectory=")) {
|
||||||
|
pluginsDirectory = args[i].substring("pluginsDirectory=".length());
|
||||||
|
// 移除引号(如果存在)
|
||||||
|
if (pluginsDirectory.startsWith("\"") && pluginsDirectory.endsWith("\"")) {
|
||||||
|
pluginsDirectory = pluginsDirectory.substring(1, pluginsDirectory.length() - 1);
|
||||||
|
}
|
||||||
|
// 不添加到剩余参数中
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 其他参数保留
|
||||||
|
remainingArgs.add(args[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Map<String, String>> validFiles = ArgsParser.parseArgs(args);
|
// 如果有设置插件目录,在这里进行设置
|
||||||
|
if (pluginsDirectory != null && !pluginsDirectory.isEmpty()) {
|
||||||
|
System.out.println("Setting up the plugin directory: " + pluginsDirectory);
|
||||||
|
FolderCreator.setPluginPath(pluginsDirectory);
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] processedArgs = remainingArgs.toArray(new String[0]);
|
||||||
|
|
||||||
|
List<Map<String, String>> validFiles = ArgsParser.parseArgs(processedArgs);
|
||||||
for (Map<String, String> fileInfo : validFiles) {
|
for (Map<String, String> fileInfo : validFiles) {
|
||||||
String extension = fileInfo.get("extension");
|
String extension = fileInfo.get("extension");
|
||||||
String path = fileInfo.get("path");
|
String path = fileInfo.get("path");
|
||||||
@@ -79,7 +104,8 @@ public class Main {
|
|||||||
if (!acquireLock()) {
|
if (!acquireLock()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
AxisInnovatorsBox.run(args, debugWindowEnabled);
|
|
||||||
|
AxisInnovatorsBox.run(processedArgs, debugWindowEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -20,6 +20,13 @@ public class FolderCreator {
|
|||||||
public static final String LANGUAGE_PATH = "language";
|
public static final String LANGUAGE_PATH = "language";
|
||||||
public static final String CONFIGURATION_PATH = "state";
|
public static final String CONFIGURATION_PATH = "state";
|
||||||
public static final String JAVA_SCRIPT_PATH = "javascript";
|
public static final String JAVA_SCRIPT_PATH = "javascript";
|
||||||
|
|
||||||
|
public static String PLUGIN_PATH_ = "";
|
||||||
|
|
||||||
|
public static void setPluginPath(String pluginPath) {
|
||||||
|
PLUGIN_PATH_ = pluginPath;
|
||||||
|
}
|
||||||
|
|
||||||
public static String getConfigurationFolder() {
|
public static String getConfigurationFolder() {
|
||||||
String folder = createFolder(CONFIGURATION_PATH);
|
String folder = createFolder(CONFIGURATION_PATH);
|
||||||
if (folder == null) {
|
if (folder == null) {
|
||||||
@@ -46,6 +53,9 @@ public class FolderCreator {
|
|||||||
return folder;
|
return folder;
|
||||||
}
|
}
|
||||||
public static String getPluginFolder() {
|
public static String getPluginFolder() {
|
||||||
|
if (!PLUGIN_PATH_.isEmpty()){
|
||||||
|
return PLUGIN_PATH_;
|
||||||
|
}
|
||||||
String folder = createFolder(PLUGIN_PATH);
|
String folder = createFolder(PLUGIN_PATH);
|
||||||
if (folder == null) {
|
if (folder == null) {
|
||||||
logger.error("Plugin folder creation failed, please use administrator privileges to execute this procedure");
|
logger.error("Plugin folder creation failed, please use administrator privileges to execute this procedure");
|
||||||
|
|||||||
Reference in New Issue
Block a user