提交 22122486 authored 作者: zhangshuang's avatar zhangshuang

Merge branch 'master' of 192.168.1.249:ty_wyl/adaptation-master1 into zs

......@@ -144,7 +144,13 @@
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>1.10.2</version>
<version>1.9.7</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>RELEASE</version>
<scope>compile</scope>
</dependency>
</dependencies>
......
......@@ -48,4 +48,9 @@ public class ProjectController {
return projectService.deployList();
}
@PostMapping("/downLoad")
public ServerResponse downLoad(@RequestBody Project project){
return projectService.downLoad(project);
}
}
......@@ -26,6 +26,7 @@ public class Report {
@ElementCollection
public List<String> jarPath;//依赖文件的地址列表,用于编译,如果不是用版本管理工具
private String packagePath;
private int fileNum;
public enum DependenceManagement{
MAVEN,GRADLE,ANT
......
......@@ -30,9 +30,10 @@ public class Rule {
private Integer status = 1;//状态(0:删除 1:未删除)
private MatchType pathMatchType;//文件匹配方式 路径/文件名/后缀
//private MatchType pathMatchType;//文件匹配方式 路径/文件名/后缀
private String path;//文件路径匹配
private TextMatch textMatching;//文本匹配方式 全文匹配/正则匹配
//private TextMatch textMatching;//文本匹配方式 全文匹配/正则匹配
//private DealWay dealWay;//替换,在匹配字之前插入,在匹配字之后插入
/**
* AREA
......@@ -41,15 +42,15 @@ public class Rule {
private String target;//文本匹配目标
private String replacing;//更改方式 全文替换/正则替换
public enum MatchType{
PATH,NAME,SUFFIX,GLOB
}
public enum TextMatch{
AREA,CONTENT
}
public enum DealWay{
REPLACE,INSERTAFTER,INSERTBEFORE
}
// public enum MatchType{
// PATH,NAME,SUFFIX,GLOB
// }
//
// public enum TextMatch{
// AREA,CONTENT
// }
//
// public enum DealWay{
// REPLACE,INSERTAFTER,INSERTBEFORE,InsertBetween
// }
}
......@@ -7,10 +7,7 @@ import com.zjty.adaptationmaster.adaptor.repository.ProjectDao;
import com.zjty.adaptationmaster.base.enums.Const;
import com.zjty.adaptationmaster.base.response.ServerResponse;
import com.zjty.adaptationmaster.adaptor.service.AdaptationService;
import com.zjty.adaptationmaster.utils.ApusicDeployer;
import com.zjty.adaptationmaster.utils.FileUtil;
import com.zjty.adaptationmaster.utils.FileZip;
import com.zjty.adaptationmaster.utils.MavenCompiler;
import com.zjty.adaptationmaster.utils.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -87,7 +84,7 @@ public class AdaptationServiceImpl implements AdaptationService {
} catch (Exception e) {
e.printStackTrace();
}
return ServerResponse.success(filter(project1));
return ServerResponse.success(project);
}
@Override
......
......@@ -10,6 +10,7 @@ import com.zjty.adaptationmaster.adaptor.service.ProjectService;
import com.zjty.adaptationmaster.base.enums.Const;
import com.zjty.adaptationmaster.base.response.ServerResponse;
import com.zjty.adaptationmaster.utils.ApusicDeployer;
import com.zjty.adaptationmaster.utils.ZipUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
......@@ -18,6 +19,9 @@ import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
......@@ -106,4 +110,17 @@ public class ProjectServiceImpl implements ProjectService {
public ServerResponse deployList() {
return ServerResponse.success(new ApusicDeployer(Const.CTLPATH,Const.MAVENHOME).list());
}
@Override
public ServerResponse downLoad(Project project) {
try {
String projectName = project.getProjectName();
FileOutputStream zip= new FileOutputStream(new File(project.getCodeUrl()+"/"+projectName+".zip"));
ZipUtils.toZip(project.getCodeUrl(),zip,true);
return ServerResponse.success("下载成功","/uploads/"+projectName+"/"+projectName+".zip");
} catch (FileNotFoundException e) {
e.printStackTrace();
return ServerResponse.error("下载失败");
}
}
}
......@@ -18,4 +18,6 @@ public interface ProjectService {
ServerResponse findProject(Integer page , Project project);//查询项目
ServerResponse deployList();
ServerResponse downLoad(Project project);//下载代码
}
......@@ -63,6 +63,7 @@ public class Inspector {
this.report = new Report();
}
int fileNum = 0;
/**
* FileVisitResult.CONTINUE 继续遍历
* FileVisitResult.TERMINATE 中止访问
......@@ -100,6 +101,7 @@ public class Inspector {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
fileNum++;
for(Map.Entry<String,PathMatcher> entry:languageSuffixMatcherMapping.entrySet()){
if(entry.getValue().matches(file)){
languageMatchMap.get(entry.getKey()).plus();
......@@ -131,6 +133,7 @@ public class Inspector {
}
public Report analysis(){
report.setFileNum(fileNum);
report.setLanguage(Report.Language.ONLYVIEW);
for(Map.Entry<String,Counter> entry:languageMatchMap.entrySet()){
if(entry.getValue().getNumber()>0){
......
......@@ -2,7 +2,6 @@ package com.zjty.adaptationmaster.utils;
import com.zjty.adaptationmaster.adaptor.controller.WebSocketServer;
import com.zjty.adaptationmaster.adaptor.entity.Rule;
import com.zjty.adaptationmaster.adaptor.service.Impl.Adaptor;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
......@@ -11,6 +10,7 @@ import java.io.*;
import java.nio.file.Path;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.List;
import java.util.Properties;
public class ReadedFileTask implements Runnable {
......@@ -20,15 +20,20 @@ public class ReadedFileTask implements Runnable {
private List<ReadedFile> readedFiles;
//private Writer responseWriter;
public ReadedFileTask(List<ReadedFile> readedFiles,String projectName,String uuid) {
//System.out.println("一个线程");
this.readedFiles = readedFiles;
for(ReadedFile file:readedFiles){
System.out.println(file.path);
}
this.projectName = projectName;
this.uuid = uuid;
}
private Adaptor.WriterBySort bySort;
private WriterBySort bySort;
private int index;
public void setBySort(Adaptor.WriterBySort bySort) {
public void setBySort(WriterBySort bySort) {
System.out.println("线程遇到大文件");
this.bySort = bySort;
}
......@@ -38,42 +43,51 @@ public class ReadedFileTask implements Runnable {
@Override
public void run() {
for(ReadedFile readedFile:readedFiles){
String content = readedFile.getContent();
System.out.println("规则数量"+readedFile.getThisMatchedRule().size());
for(Rule entity:readedFile.getThisMatchedRule()){
System.out.println("文本匹配方式"+entity.getTextMatching());
switch (entity.getTextMatching()){
case AREA:
String[] split = entity.getTarget().split("\\|\\|");
String begin = split[0];
String matching = split[1];
String end = split[2];
System.out.println(begin+"||"+matching+"||"+end);
System.out.println("进来线程");
for(ReadedFile readedFile:readedFiles) {
if(readedFile.path.toString().endsWith(".properties")){
Properties properties = new Properties();
OutputStream stream =null;
try {
properties.load(new ByteArrayInputStream(readedFile.content.getBytes()));
for (Rule entity : readedFile.getThisMatchedRule()) {
int i = content.indexOf(matching);
if(i>-1){
WebSocketServer.sendInfo(uuid,readedFile.getPath().getFileName()+":"+matching+" 替换为 "+entity.getReplacing(),"替换","正在替换",projectName);
int beginIndex = content.lastIndexOf(begin, i);
int endIndex = content.indexOf(end, i + 1);
if(beginIndex>-1&&endIndex>-1){
content = content.substring(0,beginIndex)+entity.getReplacing()+content.substring(endIndex+end.length());
}
}
//if(properties.getProperty(entity.getTarget())!=null) {
properties.setProperty(entity.getTarget(), entity.getReplacing());
//}
System.out.println("属性修改后"+properties.getProperty(entity.getTarget()));
}
readedFile.getPath().toFile().createNewFile();
stream = new FileOutputStream(readedFile.getPath().toFile());
System.out.println(properties);
properties.store(stream,"111");
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally {
try {
stream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
//container.add(readedFile.getPath().getFileName()+"文本替换:"+entity.getTextMatching()+"|"+entity.getReplacing());
//template.convertAndSend("===="+readedFile.getPath().getFileName()+"////"+entity.getTextMatching()+"||||"+entity.getReplacing(),"1L");
//responseWriter.write("===="+readedFile.getPath().getFileName()+"////"+entity.getTextMatching()+"||||"+entity.getReplacing());
continue;
}
String content = readedFile.getContent();
System.out.println("规则数量" + readedFile.getThisMatchedRule().size());
for (Rule entity : readedFile.getThisMatchedRule()) {
//在改动的地方加日志
// int i = content.indexOf(entity.getTarget());
// int i1 = content.lastIndexOf("\\r\\n", i);
//
content = content.replaceAll(entity.getTarget(),entity.getReplacing());
}
try {
if(bySort!=null){
System.out.println("toBySort");
bySort.insert(index,content);
if (bySort != null) {
bySort.insert(index, content);
} else {
System.out.println("writerFile");
WebSocketServer.sendInfo(uuid,readedFile.getPath().getFileName()+"","替换","正在写出",projectName);
WebSocketServer.sendInfo(uuid, readedFile.getPath().getFileName() + "", "替换", "正在写出", projectName);
File file = readedFile.getPath().toFile();
file.createNewFile();
OutputStreamWriter contentWriter = new OutputStreamWriter(new FileOutputStream(file));
......@@ -83,6 +97,7 @@ public class ReadedFileTask implements Runnable {
} catch (IOException e) {
e.printStackTrace();
}
}
}
......
//package com.zjty.adaptationmaster.utils;
//
//import com.zjty.adaptationmaster.adaptor.controller.WebSocketServer;
//import com.zjty.adaptationmaster.adaptor.entity.Rule;
//import lombok.AllArgsConstructor;
//import lombok.Data;
//import lombok.NoArgsConstructor;
//
//import java.io.*;
//import java.nio.file.Path;
//import java.nio.file.attribute.BasicFileAttributes;
//import java.util.List;
//import java.util.Properties;
//
//
//public class ReadedFileTask implements Runnable {
//
// private String projectName;
// private String uuid;
// private List<ReadedFile> readedFiles;
// //private Writer responseWriter;
// public ReadedFileTask(List<ReadedFile> readedFiles,String projectName,String uuid) {
// //System.out.println("一个线程");
// this.readedFiles = readedFiles;
// for(ReadedFile file:readedFiles){
// System.out.println(file.path);
// }
// this.projectName = projectName;
// this.uuid = uuid;
// }
//
// private WriterBySort bySort;
// private int index;
//
// public void setBySort(WriterBySort bySort) {
// System.out.println("线程遇到大文件");
// this.bySort = bySort;
// }
//
// public void setIndex(int index) {
// this.index = index;
// }
//
// @Override
// public void run() {
// System.out.println("进来线程");
// for(ReadedFile readedFile:readedFiles) {
// if(readedFile.path.toString().endsWith(".properties")){
// Properties properties = new Properties();
// OutputStream stream =null;
// try {
// properties.load(new ByteArrayInputStream(readedFile.content.getBytes()));
// for (Rule entity : readedFile.getThisMatchedRule()) {
//
// //if(properties.getProperty(entity.getTarget())!=null) {
// properties.setProperty(entity.getTarget(), entity.getReplacing());
// //}
// System.out.println("属性修改后"+properties.getProperty(entity.getTarget()));
// }
// readedFile.getPath().toFile().createNewFile();
// stream = new FileOutputStream(readedFile.getPath().toFile());
// System.out.println(properties);
// properties.store(stream,"111");
// } catch (FileNotFoundException e) {
// e.printStackTrace();
// } catch (IOException e) {
// e.printStackTrace();
// }finally {
// try {
// stream.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// continue;
// }
// String content = readedFile.getContent();
// System.out.println("规则数量" + readedFile.getThisMatchedRule().size());
// for (Rule entity : readedFile.getThisMatchedRule()) {
// System.out.println("文本匹配方式" + entity.getTextMatching());
// switch (entity.getTextMatching()) {
// case AREA:
// System.out.println("case");
// String[] split = entity.getTarget().split("\\|\\|");
// String begin = split[0];
// String matching = split[1];
// String end = split[2];
// System.out.println(begin + "||" + matching + "||" + end);
//
// int i = content.indexOf(matching);
// if (i > -1) {
// System.out.println("i" + i);
// WebSocketServer.sendInfo(uuid, readedFile.getPath().getFileName() + ":" + matching + " 替换为 " + entity.getReplacing(), "替换", "正在替换", projectName);
// int beginIndex = content.lastIndexOf(begin, i);
// int endIndex = content.indexOf(end, i + 1);
// if (beginIndex > -1 && endIndex > -1) {
// content = content.substring(0, beginIndex) + entity.getReplacing() + content.substring(endIndex + end.length());
// }
// } else {
//
// System.out.println("-i" + i);
// }
// break;
// case CONTENT:
// switch (entity.getDealWay()) {
// case REPLACE:
// content = content.replaceAll(entity.getTarget(), entity.getReplacing());
// break;
// case INSERTAFTER:
// //判断是不是本来就有,如果已有,就不用新增了
// //if(content.indexOf(entity.getReplacing(),content.indexOf(entity.getTarget()))==-1) {
// int insertPlace = content.indexOf(entity.getTarget()) + entity.getTarget().length();
// content = content.substring(0, insertPlace) + entity.getReplacing() + content.substring(insertPlace);
// //}
// break;
// case INSERTBEFORE:
// break;
// case InsertBetween:
// break;
// }
//
// break;
// }
// }
// try {
// if (bySort != null) {
// bySort.insert(index, content);
// } else {
// WebSocketServer.sendInfo(uuid, readedFile.getPath().getFileName() + "", "替换", "正在写出", projectName);
// File file = readedFile.getPath().toFile();
// file.createNewFile();
// OutputStreamWriter contentWriter = new OutputStreamWriter(new FileOutputStream(file));
// contentWriter.write(content);
// contentWriter.close();
// }
// } catch (IOException e) {
// e.printStackTrace();
// }
//
// }
// }
//
// @Data
// @NoArgsConstructor
// @AllArgsConstructor
// public static class ReadedFile {
// private String content;
// private BasicFileAttributes attributes;
// private Path path;
// private List<Rule> thisMatchedRule;
// }
//}
package com.zjty.adaptationmaster.utils;
import java.io.IOException;
import java.io.Writer;
import java.util.Map;
import java.util.TreeMap;
public class WriterBySort {
private int currentIndex = -1;
private Map<Integer,String> map = new TreeMap<>();
private Writer contentWriter;
private int size;
public void setWriter(Writer writer) {
this.contentWriter = writer;
}
public void setSize(int size) {
this.size = size;
if(currentIndex==size){
try {
contentWriter.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
public void insert(Integer key, String value){
map.put(key,value);
while (map.get(currentIndex+1)!=null){
try {
contentWriter.write(map.remove(currentIndex+1));
} catch (IOException e) {
e.printStackTrace();
}
currentIndex++;
if(currentIndex == size){
try {
contentWriter.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
package com.zjty.adaptationmaster.utils;
import java.io.*;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
public class ZipUtils {
private static final int BUFFER_SIZE = 2 * 1024;
/**
* 压缩成ZIP 方法 * @param srcDir 压缩文件夹路径
* @param out 压缩文件输出流
* @param KeepDirStructure 是否保留原来的目录结构,true:保留目录结构;
* false:所有文件跑到压缩包根目录下(注意:不保留目录结构可能会出现同名文件,会压缩失败)
* @throws RuntimeException 压缩失败会抛出运行时异常
*/
public static void toZip(String srcDir, OutputStream out, boolean KeepDirStructure)
throws RuntimeException{
long start = System.currentTimeMillis();
ZipOutputStream zos = null ;
try {
zos = new ZipOutputStream(out);
File sourceFile = new File(srcDir);
compress(sourceFile,zos,sourceFile.getName(),KeepDirStructure);
long end = System.currentTimeMillis();
System.out.println("压缩完成,耗时:" + (end - start) +" ms");
} catch (Exception e) {
throw new RuntimeException("zip error from ZipUtils",e);
}finally{
if(zos != null){
try {
zos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
/**
* 压缩成ZIP 方法 * @param srcFiles 需要压缩的文件列表
* @param out 压缩文件输出流
* @throws RuntimeException 压缩失败会抛出运行时异常
*/
public static void toZip(List<File> srcFiles , OutputStream out)throws RuntimeException {
long start = System.currentTimeMillis();
ZipOutputStream zos = null ;
try {
zos = new ZipOutputStream(out);
for (File srcFile : srcFiles) {
byte[] buf = new byte[BUFFER_SIZE];
zos.putNextEntry(new ZipEntry(srcFile.getName()));
int len;
FileInputStream in = new FileInputStream(srcFile);
while ((len = in.read(buf)) != -1){
zos.write(buf, 0, len);
}
zos.closeEntry();
in.close();
}
long end = System.currentTimeMillis();
System.out.println("压缩完成,耗时:" + (end - start) +" ms");
} catch (Exception e) {
throw new RuntimeException("zip error from ZipUtils",e);
}finally{
if(zos != null){
try {
zos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
/**
* 递归压缩方法
* @param sourceFile 源文件
* @param zos zip输出流
* @param name 压缩后的名称
* @param KeepDirStructure 是否保留原来的目录结构,true:保留目录结构;
* false:所有文件跑到压缩包根目录下(注意:不保留目录结构可能会出现同名文件,会压缩失败)
* @throws Exception
*/
private static void compress(File sourceFile, ZipOutputStream zos, String name,
boolean KeepDirStructure) throws Exception{
byte[] buf = new byte[BUFFER_SIZE];
if(sourceFile.isFile()){
// 向zip输出流中添加一个zip实体,构造器中name为zip实体的文件的名字
zos.putNextEntry(new ZipEntry(name));
// copy文件到zip输出流中
int len;
FileInputStream in = new FileInputStream(sourceFile);
while ((len = in.read(buf)) != -1){
zos.write(buf, 0, len);
}
// Complete the entry
zos.closeEntry();
in.close();
} else {
//是文件夹
File[] listFiles = sourceFile.listFiles();
if(listFiles == null || listFiles.length == 0){
// 需要保留原来的文件结构时,需要对空文件夹进行处理
if(KeepDirStructure){
// 空文件夹的处理
zos.putNextEntry(new ZipEntry(name + "/"));
// 没有文件,不需要文件的copy
zos.closeEntry();
}
}else {
for (File file : listFiles) {
// 判断是否需要保留原来的文件结构
if (KeepDirStructure) {
// 注意:file.getName()前面需要带上父文件夹的名字加一斜杠,
// 不然最后压缩包中就不能保留原来的文件结构,即:所有文件都跑到压缩包根目录下了
compress(file, zos, name + "/" + file.getName(),KeepDirStructure);
} else {
compress(file, zos, file.getName(),KeepDirStructure);
}
}
}
}
}
public static void main(String[] args) throws Exception {
/** 测试压缩方法 */
FileOutputStream fos1= new FileOutputStream(new File("C:\\Users\\xiaoge\\Desktop\\领导.zip"));
ZipUtils.toZip("C:\\Users\\xiaoge\\Desktop\\右侧\\领导", fos1,true);
}
}
......@@ -9,6 +9,7 @@ import java.nio.file.PathMatcher;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
public class Test1 {
@Test
......@@ -684,4 +685,9 @@ public class Test1 {
System.out.println(sb.toString());
}
@Test
public void test5(){
System.out.println(Pattern.matches(".+22.+","2223"));
}
}
//package com.zjty.adaptationmaster;
//
//import com.zjty.adaptationmaster.adaptor.entity.Project;
//import com.zjty.adaptationmaster.adaptor.entity.Rule;
//import com.zjty.adaptationmaster.adaptor.service.Impl.Adaptor;
//import org.junit.Test;
//
//import java.nio.file.FileSystems;
//import java.nio.file.Path;
//import java.nio.file.Paths;
//import java.util.ArrayList;
//import java.util.List;
//
//public class TestAdapt {
//
// public static void main(String[] args) {
// List ruleList = new ArrayList();
// Rule rule = new Rule();
// rule.setPathMatchType(Rule.MatchType.NAME);
// rule.setPath("pom.xml");
// rule.setTextMatching(Rule.TextMatch.CONTENT);
// rule.setDealWay(Rule.DealWay.REPLACE);
// rule.setTarget("<packaging>jar</packaging>");
// rule.setReplacing("<packaging>war</packaging>");
// ruleList.add(rule);
//
// Rule rule11 = new Rule();
// rule11.setPathMatchType(Rule.MatchType.NAME);
// rule11.setPath("pom.xml");
// rule11.setTextMatching(Rule.TextMatch.CONTENT);
// rule11.setDealWay(Rule.DealWay.INSERTAFTER);
// rule11.setTarget("<dependencies>");
// rule11.setReplacing("<dependency>\n" +
// " <groupId>org.postgresql</groupId>\n" +
// " <artifactId>postgresql</artifactId>\n" +
// " <scope>runtime</scope>\n" +
// " </dependency>");
// ruleList.add(rule11);
//
// Rule rule1 = new Rule();
// rule1.setPathMatchType(Rule.MatchType.GLOB);
// rule1.setPath("**/application**.properties");
// rule1.setTextMatching(Rule.TextMatch.CONTENT);
// rule1.setDealWay(Rule.DealWay.REPLACE);
// rule1.setTarget("spring.datasource.driver-class-name");
// rule1.setReplacing("org.postgresql.Driver");
// ruleList.add(rule1);
//
// Rule rule2 = new Rule();
// rule2.setPathMatchType(Rule.MatchType.GLOB);
// rule2.setPath("**/application**.properties");
// rule2.setTextMatching(Rule.TextMatch.CONTENT);
// rule2.setDealWay(Rule.DealWay.REPLACE);
// rule2.setTarget("spring.datasource.url");
// rule2.setReplacing("jdbc:postgresql://localhost:5866/hrm");
// ruleList.add(rule2);
// Rule rule3 = new Rule();
// rule3.setPathMatchType(Rule.MatchType.GLOB);
// rule3.setPath("**/application**.properties");
// rule3.setTextMatching(Rule.TextMatch.CONTENT);
// rule3.setDealWay(Rule.DealWay.REPLACE);
// rule3.setTarget("spring.datasource.username");
// rule3.setReplacing("sysdba");
// ruleList.add(rule3);
// Rule rule4 = new Rule();
// rule4.setPathMatchType(Rule.MatchType.GLOB);
// rule4.setPath("**/application**.properties");
// rule4.setTextMatching(Rule.TextMatch.CONTENT);
// rule4.setDealWay(Rule.DealWay.REPLACE);
// rule4.setTarget("spring.datasource.password");
// rule4.setReplacing("highgo@123");
// ruleList.add(rule4);
// Rule rule5 = new Rule();
// rule5.setPathMatchType(Rule.MatchType.GLOB);
// rule5.setPath("**/application**.properties");
// rule5.setTextMatching(Rule.TextMatch.CONTENT);
// rule5.setDealWay(Rule.DealWay.REPLACE);
// rule5.setTarget("spring.jpa.database-platform");
// rule5.setReplacing("org.hibernate.dialect.PostgreSQLDialect");
// ruleList.add(rule5);
//
// Adaptor adaptor = new Adaptor();
// adaptor.setRuleList(ruleList);
// adaptor.setUuid("111");
// Project project = new Project();
// project.setCodeUrl("C:\\home\\project\\rsc\\hrmbclient");
// project.setProjectName("hrm");
// adaptor.setProject(project);
// adaptor.doAdapt();
// }
// @Test
// public void test(){
// Path path = Paths.get("D:/aaa.properties");
// System.out.println(path.toString().endsWith(".properties"));
// }
//}
package com.zjty.adaptationmaster;
import com.zjty.adaptationmaster.adaptor.controller.WebSocketServer;
import java.io.*;
public class TestProcess {
public static void main(String[] args) {
try {
Process exec = Runtime.getRuntime().exec("C:/Users/wyl/Desktop/national/AAS-V9.0/bin/appctl.cmd install -p Qwer123!@# hrm C://home/project/rsc/hrmbclient/target/hrmanager-0.0.1-SNAPSHOT.war");
BufferedReader reader = new BufferedReader(new InputStreamReader(exec.getInputStream()));
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(exec.getOutputStream()));
String line = null;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
writer.write("@Qwer123!@#");
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论