Commit c98d5df8 authored by qiaokun's avatar qiaokun

删除临时web.xml文件由deleteOnExit方法切换到delete方法

parent 0e6905af
......@@ -22,7 +22,6 @@ import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.jar.JarFile;
public class Bootstrap implements Container {
......@@ -41,20 +40,25 @@ public class Bootstrap implements Container {
private String context;
public Bootstrap() {
this(System.getProperty("user.dir"), webapp, webapp, "destWork");
}
public Bootstrap(String originRoot) {
this(originRoot, webapp, webapp, "destWork");
}
public Bootstrap(String originRoot, String destRoot) {
this(originRoot, webapp, destRoot, "destWork");
}
public Bootstrap(String originRoot, String webapp, String destRoot, String destDirectory) {
//设置默认context为当前项目名称
String projectPath = System.getProperty("user.dir");
File temp = new File(projectPath);
this.context = temp.getName();
this.projectPath = originRoot;
this.originWebappFile = new File(projectPath, webapp);
......@@ -64,7 +68,7 @@ public class Bootstrap implements Container {
clearAndCompile(originWebappFile, destDirectoryFile);
this.monitor(originWebappFile.getAbsolutePath(),
new FileListener(originWebappFile.getAbsolutePath(), this.destDirectoryFile.getAbsolutePath()));
} else{
} else {
this.destDirectoryFile = this.originWebappFile;
}
}
......@@ -111,14 +115,17 @@ public class Bootstrap implements Container {
final String testclasses = new File(projectPath, "target/test-classes").getAbsolutePath();
final File webXml = new File(testclasses,"web.xml");
final File webXml = new File(testclasses, "web.xml");
webXml.deleteOnExit();
if (webXml.exists()) {
webXml.delete();
}
FileUtils.copyURLToFile(getClass().getResource("/web.xml"),webXml);
FileUtils.copyURLToFile(getClass().getResource("/web.xml"), webXml);
Tomcat tomcat = new Tomcat() {
@Override
public Context addWebapp(Host host, String url, String name, String path) {
......@@ -131,7 +138,7 @@ public class Bootstrap implements Container {
ContextConfig ctxCfg = new ContextConfig();
ctx.addLifecycleListener(ctxCfg);
ctxCfg.setDefaultWebXml(new File(testclasses,"web.xml").getPath());
ctxCfg.setDefaultWebXml(new File(testclasses, "web.xml").getPath());
if (host == null) {
getHost().addChild(ctx);
} else {
......
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