Commit 287d8ebb by fengshuonan

更新

parent f4974216
package cn.stylefeng.guns; package cn.stylefeng.guns;
import java.io.File; import java.io.File;
import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -12,12 +13,12 @@ public class MavenDeployLocalFile { ...@@ -12,12 +13,12 @@ public class MavenDeployLocalFile {
/** /**
* 当前工作目录 * 当前工作目录
*/ */
private String CURRENT_PATH = "/Users/stylefeng/tmp/"; private String CURRENT_PATH = "/Users/stylefeng/work/repository/";
/** /**
* 仓库的地址 * 仓库的地址
*/ */
private String REPO_PATH = "/Users/stylefeng/tmp/share"; private String REPO_PATH = "/Users/stylefeng/work/repository";
/** /**
* maven的settings文件配置路径 * maven的settings文件配置路径
...@@ -34,6 +35,8 @@ public class MavenDeployLocalFile { ...@@ -34,6 +35,8 @@ public class MavenDeployLocalFile {
*/ */
private String REPOSITORY_URL = "http://172.23.2.3:8081/repository/maven-host-sedinBJ/"; private String REPOSITORY_URL = "http://172.23.2.3:8081/repository/maven-host-sedinBJ/";
private List<String> finalCommands = new ArrayList<>();
/** /**
* 递归获取一个目录下的所有文件目录路径 * 递归获取一个目录下的所有文件目录路径
* *
...@@ -167,6 +170,9 @@ public class MavenDeployLocalFile { ...@@ -167,6 +170,9 @@ public class MavenDeployLocalFile {
doOnlyPom(directory); doOnlyPom(directory);
} }
} }
//输出文件
writeToFile("/Users/stylefeng/tmp/bash.sh", finalCommands);
} }
/** /**
...@@ -177,15 +183,43 @@ public class MavenDeployLocalFile { ...@@ -177,15 +183,43 @@ public class MavenDeployLocalFile {
*/ */
private void executeCommand(String command) { private void executeCommand(String command) {
try { try {
Process exec = Runtime.getRuntime().exec(command); System.out.println(command);
int i = exec.waitFor(); finalCommands.add(command);
System.out.println("执行结果:" + i); //Process exec = Runtime.getRuntime().exec(command);
} catch (IOException | InterruptedException e) { //int i = exec.waitFor();
//System.out.println("执行结果:" + i);
} catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
/** /**
* 写出到文件
*
* @author fengshuonan
* @Date 2018/11/18 1:04 PM
*/
private void writeToFile(String path, List<String> lists) {
File file = new File(path);
FileWriter fileWriter = null;
try {
fileWriter = new FileWriter(file);
for (String list : lists) {
fileWriter.write(list + "\n");
}
fileWriter.flush();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
fileWriter.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
/**
* 构造command命令 * 构造command命令
* *
* @author fengshuonan * @author fengshuonan
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment