1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 package org.utgenome.shell;
26
27 import java.io.File;
28
29 import org.utgenome.config.UTGBConfig;
30 import org.xerial.util.FileUtil;
31 import org.xerial.util.opt.Option;
32
33 public class Deploy extends UTGBShellCommand {
34
35 @Option(symbol = "p", longName = "path", varName = "CONTEXT_PATH", description = "web application's context path. e.g., myapp")
36 private String contextPath = null;
37
38 @Option(symbol = "n", description = "do not generate context.xml")
39 boolean noContextXML = false;
40
41 @Option(symbol = "c", longName = "clean", description = "force recompilation of the project (utgb clean, utgb compile), then deploy")
42 boolean forceClean = false;
43
44 public Deploy() {
45 }
46
47 @Override
48 public void execute(String[] args) throws Exception {
49 if (!isInProjectRoot())
50 throw new UTGBShellException("not in the project root");
51
52
53 FileUtil.mkdirs(new File(getProjectRoot(), "war/utgb"));
54
55 if (forceClean) {
56 UTGBShell.runCommand(globalOption, "clean");
57 UTGBShell.runCommand(globalOption, "compile");
58 }
59
60 UTGBConfig config = loadUTGBConfig();
61
62 if (!noContextXML)
63 createContextXML(contextPath != null ? contextPath : config.projectName, new File("").getAbsolutePath(), false);
64 maven("tomcat:deploy -U" + (contextPath != null ? " -Dpath=/" + contextPath : ""));
65 }
66
67 @Override
68 public String name() {
69 return "deploy";
70 }
71
72 @Override
73 public String getOneLinerDescription() {
74 return "deploy the project (war file) to the remote Tomcat server";
75 }
76
77 }