!482 [napi_tool] 删除java代码中使用系统命令方式的代码

Merge pull request !482 from 苟晶晶/master
This commit is contained in:
openharmony_ci 2024-11-19 06:14:29 +00:00 committed by Gitee
commit d4be7064d3
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 0 additions and 46 deletions

View File

@ -290,7 +290,6 @@ public class GenDialogPane extends JDialog implements SelectOutDirAction.SelectP
execFn = "cmds/mac/gn-gen-macos"; execFn = "cmds/mac/gn-gen-macos";
tmpDirFile += "/gn-gen-macos"; tmpDirFile += "/gn-gen-macos";
} }
File file = new File(tmpDirFile);
writeTmpFile(tmpDirFile, execFn, project); writeTmpFile(tmpDirFile, execFn, project);
if (SYS_NAME.contains("LINUX") || SYS_NAME.contains("MAC OS")) { if (SYS_NAME.contains("LINUX") || SYS_NAME.contains("MAC OS")) {
try { try {
@ -319,7 +318,6 @@ public class GenDialogPane extends JDialog implements SelectOutDirAction.SelectP
makeFilePath = "cmds/res/win/bin/make.exe"; makeFilePath = "cmds/res/win/bin/make.exe";
} }
String tmpDirFile = System.getProperty("java.io.tmpdir") + "/res/linux/bin/"; String tmpDirFile = System.getProperty("java.io.tmpdir") + "/res/linux/bin/";
File file = new File(tmpDirFile);
if (file.mkdirs()) { if (file.mkdirs()) {
LOG.info("create dir success"); LOG.info("create dir success");
} }
@ -342,7 +340,6 @@ public class GenDialogPane extends JDialog implements SelectOutDirAction.SelectP
makeFilePath = "cmds/res/win/bin/make_raw.exe"; makeFilePath = "cmds/res/win/bin/make_raw.exe";
} }
String tmpDirFile = System.getProperty("java.io.tmpdir") + "/res/linux/bin/"; String tmpDirFile = System.getProperty("java.io.tmpdir") + "/res/linux/bin/";
File file = new File(tmpDirFile);
if (file.mkdirs()) { if (file.mkdirs()) {
LOG.info("create dir success"); LOG.info("create dir success");
} }
@ -365,7 +362,6 @@ public class GenDialogPane extends JDialog implements SelectOutDirAction.SelectP
toolchainFileDir = "cmds/res/win/ohos.toolchain.cmake"; toolchainFileDir = "cmds/res/win/ohos.toolchain.cmake";
} }
String tmpDirFile = System.getProperty("java.io.tmpdir") + "/res/linux/"; String tmpDirFile = System.getProperty("java.io.tmpdir") + "/res/linux/";
File file = new File(tmpDirFile);
if (file.mkdirs()) { if (file.mkdirs()) {
LOG.info("create dir success"); LOG.info("create dir success");
} }
@ -387,10 +383,6 @@ public class GenDialogPane extends JDialog implements SelectOutDirAction.SelectP
GenNotification.notifyMessage(this.project, "执行命令文件为空", "空命令行提示", NotificationType.ERROR); GenNotification.notifyMessage(this.project, "执行命令文件为空", "空命令行提示", NotificationType.ERROR);
return false; return false;
} }
final Process process = Runtime.getRuntime().exec(command);
threadPool.execute(new BlockThread(process));
StreamConsumer errConsumer = new StreamConsumer(process.getErrorStream());
StreamConsumer outputConsumer = new StreamConsumer(process.getInputStream());
errConsumer.start(); errConsumer.start();
outputConsumer.start(); outputConsumer.start();
if (generateSuccess) { if (generateSuccess) {
@ -425,10 +417,6 @@ public class GenDialogPane extends JDialog implements SelectOutDirAction.SelectP
BufferedReader stdInput = null; BufferedReader stdInput = null;
BufferedReader stdError = null; BufferedReader stdError = null;
try { try {
stdInput = new BufferedReader(new InputStreamReader(process.getInputStream(),
StandardCharsets.UTF_8));
stdError = new BufferedReader(new InputStreamReader(process.getErrorStream(),
StandardCharsets.UTF_8));
String sErr = ''; String sErr = '';
String sOut; String sOut;
sErr = getErrorResult(stdError); sErr = getErrorResult(stdError);
@ -569,8 +557,6 @@ public class GenDialogPane extends JDialog implements SelectOutDirAction.SelectP
public void run() { public void run() {
BufferedReader br1 = null; BufferedReader br1 = null;
try { try {
br1 = new BufferedReader(new InputStreamReader(process.getInputStream(),
StandardCharsets.UTF_8));
genResultLog(process); genResultLog(process);
while (br1.readLine() != null) { while (br1.readLine() != null) {
LOG.info(" callExtProcess "); LOG.info(" callExtProcess ");

View File

@ -269,7 +269,6 @@ public class GenerateDialogPane extends JDialog {
copyFileToLocalPath("napi_generator-macos"); copyFileToLocalPath("napi_generator-macos");
tmpDirFile += "napi_generator-macos"; tmpDirFile += "napi_generator-macos";
} }
File file = new File(tmpDirFile);
String command = file.toString(); String command = file.toString();
String inArgs = genInArgs(interFileOrDir); String inArgs = genInArgs(interFileOrDir);
command += inArgs + " -o " + genOutDir + " -i " + radioButton.isSelected() + " -n " + genNumbertypeArgs(); command += inArgs + " -o " + genOutDir + " -i " + radioButton.isSelected() + " -n " + genNumbertypeArgs();
@ -371,10 +370,6 @@ public class GenerateDialogPane extends JDialog {
GenNotification.notifyMessage(this.project, "执行命令文件为空", "空命令行提示", NotificationType.ERROR); GenNotification.notifyMessage(this.project, "执行命令文件为空", "空命令行提示", NotificationType.ERROR);
return false; return false;
} }
Process process = Runtime.getRuntime().exec(command);
genResultLog(process);
StreamConsumer errConsumer = new StreamConsumer(process.getErrorStream());
StreamConsumer outputConsumer = new StreamConsumer(process.getInputStream());
errConsumer.start(); errConsumer.start();
outputConsumer.start(); outputConsumer.start();
@ -599,10 +594,6 @@ public class GenerateDialogPane extends JDialog {
BufferedReader stdInput = null; BufferedReader stdInput = null;
BufferedReader stdError = null; BufferedReader stdError = null;
try { try {
stdInput = new BufferedReader(new InputStreamReader(process.getInputStream(),
StandardCharsets.UTF_8));
stdError = new BufferedReader(new InputStreamReader(process.getErrorStream(),
StandardCharsets.UTF_8));
String sErr; String sErr;
String sOut; String sOut;
sErr = getErrorResult(stdError); sErr = getErrorResult(stdError);

View File

@ -277,10 +277,6 @@ public class GenerateDialogPane extends JDialog {
GenNotification.notifyMessage(this.project, "执行命令文件为空", "空命令行提示", NotificationType.ERROR); GenNotification.notifyMessage(this.project, "执行命令文件为空", "空命令行提示", NotificationType.ERROR);
return false; return false;
} }
Process process = Runtime.getRuntime().exec(command);
genResultLog(process);
StreamConsumer errConsumer = new StreamConsumer(process.getErrorStream());
StreamConsumer outputConsumer = new StreamConsumer(process.getInputStream());
errConsumer.start(); errConsumer.start();
outputConsumer.start(); outputConsumer.start();
@ -345,10 +341,6 @@ public class GenerateDialogPane extends JDialog {
BufferedReader stdInput = null; BufferedReader stdInput = null;
BufferedReader stdError = null; BufferedReader stdError = null;
try { try {
stdInput = new BufferedReader(new InputStreamReader(process.getInputStream(),
StandardCharsets.UTF_8));
stdError = new BufferedReader(new InputStreamReader(process.getErrorStream(),
StandardCharsets.UTF_8));
String sErr; String sErr;
String sOut; String sOut;
sErr = getErrorResult(stdError); sErr = getErrorResult(stdError);
@ -528,7 +520,6 @@ public class GenerateDialogPane extends JDialog {
tmpDirFile += "napi_generator-macos"; tmpDirFile += "napi_generator-macos";
} }
File file = new File(tmpDirFile);
String command = file.toString(); String command = file.toString();
String inArgs = genInArgs(textFieldSelectH.getText()); String inArgs = genInArgs(textFieldSelectH.getText());
command += inArgs + " -o " + textFieldSelectOutPath.getText() + " -t " + true; command += inArgs + " -o " + textFieldSelectOutPath.getText() + " -t " + true;

View File

@ -229,10 +229,6 @@ public class GenDts extends AnAction {
GenNotification.notifyMessage(null, "执行命令文件为空", "空命令行提示", NotificationType.ERROR); GenNotification.notifyMessage(null, "执行命令文件为空", "空命令行提示", NotificationType.ERROR);
return false; return false;
} }
Process process = Runtime.getRuntime().exec(command);
genResultLog(process);
StreamConsumer errConsumer = new StreamConsumer(process.getErrorStream());
StreamConsumer outputConsumer = new StreamConsumer(process.getInputStream());
errConsumer.start(); errConsumer.start();
outputConsumer.start(); outputConsumer.start();
@ -344,7 +340,6 @@ public class GenDts extends AnAction {
tmpDirFile += "native_gen-macos"; tmpDirFile += "native_gen-macos";
} }
File file = new File(tmpDirFile);
String command = file.toString(); String command = file.toString();
command += " -f " + hFilePath; command += " -f " + hFilePath;
// 判断用户是否输入了 "-o"+cpp文件路径 "-i"+dts文件路径"-t"+test文件路径 从界面获取 // 判断用户是否输入了 "-o"+cpp文件路径 "-i"+dts文件路径"-t"+test文件路径 从界面获取

View File

@ -178,7 +178,6 @@ public class ServiceGenerateDialogPane extends JDialog {
execFn = "cmds/mac/service-gen-macos"; execFn = "cmds/mac/service-gen-macos";
tmpDirFile += "service-gen-macos"; tmpDirFile += "service-gen-macos";
} }
File file = new File(tmpDirFile);
if (!file.exists()) { if (!file.exists()) {
try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream(execFn)) { try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream(execFn)) {
if (inputStream == null) { if (inputStream == null) {
@ -241,10 +240,6 @@ public class ServiceGenerateDialogPane extends JDialog {
GenNotification.notifyMessage(this.project, "执行命令文件为空", "空命令行提示", NotificationType.ERROR); GenNotification.notifyMessage(this.project, "执行命令文件为空", "空命令行提示", NotificationType.ERROR);
return false; return false;
} }
Process process = Runtime.getRuntime().exec(command);
genResultLog(process);
StreamConsumer errConsumer = new StreamConsumer(process.getErrorStream());
StreamConsumer outputConsumer = new StreamConsumer(process.getInputStream());
errConsumer.start(); errConsumer.start();
outputConsumer.start(); outputConsumer.start();
if (generateSuccess) { if (generateSuccess) {
@ -309,10 +304,6 @@ public class ServiceGenerateDialogPane extends JDialog {
BufferedReader stdInput = null; BufferedReader stdInput = null;
BufferedReader stdError = null; BufferedReader stdError = null;
try { try {
stdInput = new BufferedReader(new InputStreamReader(process.getInputStream(),
StandardCharsets.UTF_8));
stdError = new BufferedReader(new InputStreamReader(process.getErrorStream(),
StandardCharsets.UTF_8));
String sErr; String sErr;
String sOut; String sOut;
sErr = getErrorResult(stdError); sErr = getErrorResult(stdError);