/
App.java
69 lines (55 loc) · 2.22 KB
/
App.java
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package wad;
import static com.airhacks.wad.control.PreBuildChecks.pomExists;
import static com.airhacks.wad.control.PreBuildChecks.validateDeploymentDirectories;
import com.airhacks.wad.boundary.WADFlow;
import com.airhacks.wad.control.Configurator;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
import java.util.Set;
import java.util.stream.Collectors;
/**
*
* @author airhacks.com
*/
public class App {
static Path addTrailingSlash(String path) {
if (!path.endsWith(File.separator)) {
return Paths.get(path, File.separator);
}
return Paths.get(path);
}
static void printWelcomeMessage() throws IOException {
try (InputStream resourceAsStream = App.class.
getClassLoader().
getResourceAsStream("META-INF/maven/com.airhacks/wad/pom.properties")) {
Properties properties = new Properties();
properties.load(resourceAsStream);
String wad = properties.getProperty("artifactId");
String version = properties.getProperty("version");
System.out.println(wad + " " + version);
}
}
static List<Path> convert(String[] args) {
return Arrays.stream(args).map(App::addTrailingSlash).collect(Collectors.toList());
}
public static void main(String[] args) throws IOException {
printWelcomeMessage();
if (args.length < 1 && !Configurator.userConfigurationExists()) {
System.out.println("Invoke with java -jar wad.jar [DEPLOYMENT_DIR1,DEPLOYMENT_DIR1] or create ~/.wadrc");
System.exit(-1);
}
pomExists();
Path thinWARPath = Paths.get("target");
Set<Path> deploymentDirs = Configurator.getConfiguredFolders(convert(args));
validateDeploymentDirectories(deploymentDirs);
Path sourceCodeDir = Paths.get("./src/main/");
System.out.printf("WAD is watching %s, deploying from dir '%s' to %s \n", sourceCodeDir, thinWARPath, deploymentDirs);
WADFlow wadFlow = new WADFlow(sourceCodeDir, thinWARPath, deploymentDirs);
}
}