|
1 | 1 | package br.com.gaboso; |
2 | 2 |
|
| 3 | +import br.com.gaboso.helper.FileHelper; |
3 | 4 | import br.com.gaboso.module.BowerModule; |
4 | 5 | import br.com.gaboso.module.GitModule; |
5 | 6 | import br.com.gaboso.module.GruntModule; |
6 | 7 | import br.com.gaboso.module.MavenModule; |
7 | 8 | import br.com.gaboso.module.NpmModule; |
8 | | -import org.apache.log4j.Logger; |
9 | 9 |
|
10 | 10 | import java.io.File; |
11 | | -import java.util.ArrayList; |
12 | 11 | import java.util.List; |
13 | 12 |
|
14 | 13 | /** |
15 | 14 | * @author Gaboso |
16 | 15 | * @since 19/04/2017 |
17 | | - * <p> |
18 | | - * Scriptum |
| 16 | + * <p>Scriptum</p> |
19 | 17 | */ |
20 | 18 | public class Scriptum { |
21 | 19 |
|
22 | | - private static final Logger LOGGER = Logger.getLogger(Scriptum.class); |
23 | | - |
24 | 20 | public static void main(String[] args) { |
25 | | - if (args.length > 0) { |
26 | | - Scriptum scriptum = new Scriptum(); |
27 | | - List<File> folders = scriptum.getFoldersFromWorkspace(args[0]); |
| 21 | + String workspaceDir; |
28 | 22 |
|
29 | | - for (File file : folders) { |
30 | | - scriptum.analyzeFolders(file); |
31 | | - } |
| 23 | + if (args.length > 0) { |
| 24 | + workspaceDir = args[0]; |
| 25 | + } else { |
| 26 | + workspaceDir = FileHelper.getJarDir(); |
32 | 27 | } |
33 | | - } |
34 | 28 |
|
35 | | - private List<File> getFoldersFromWorkspace(String path) { |
36 | | - File fileInitial = new File(path); |
37 | | - File[] listFiles = fileInitial.listFiles(); |
38 | | - List<File> folders = new ArrayList<>(); |
| 29 | + List<File> folders = FileHelper.getFoldersFromWorkspace(workspaceDir); |
39 | 30 |
|
40 | | - if (listFiles != null) { |
41 | | - LOGGER.info("------------- LISTA DE DIRETORIOS DO WORKSPACE -------------"); |
42 | | - for (File file : listFiles) { |
43 | | - if (file.isDirectory()) { |
44 | | - folders.add(file); |
45 | | - LOGGER.info(file.getName()); |
46 | | - } |
47 | | - } |
48 | | - LOGGER.info("------------------------------------------------------------"); |
| 31 | + for (File file : folders) { |
| 32 | + Scriptum.analyzeFolders(file); |
49 | 33 | } |
50 | 34 |
|
51 | | - return folders; |
52 | 35 | } |
53 | 36 |
|
54 | | - private void analyzeFolders(File file) { |
| 37 | + private static void analyzeFolders(File file) { |
55 | 38 | File[] listFiles = file.listFiles(); |
56 | 39 |
|
57 | | - //Is Git Project |
58 | 40 | if (GitModule.isProject(file.getPath())) { |
59 | 41 | GitModule.executeCommands(file.getName(), file.getPath()); |
60 | 42 | } |
61 | 43 |
|
62 | 44 | if (listFiles != null) { |
63 | 45 |
|
64 | | - //Is Maven Project |
65 | 46 | if (MavenModule.isProject(listFiles)) { |
66 | 47 | MavenModule.executeCommands(file.getName(), file.getPath()); |
67 | 48 | } |
68 | 49 |
|
69 | | - //Is npm Project |
70 | 50 | if (NpmModule.isProject(listFiles)) { |
71 | 51 | NpmModule.executeCommands(file.getName(), file.getPath()); |
72 | 52 | } |
73 | 53 |
|
74 | | - //Is Bower Project |
75 | 54 | if (BowerModule.isProject(listFiles)) { |
76 | 55 | BowerModule.executeCommands(file.getName(), file.getPath()); |
77 | 56 | } |
78 | 57 |
|
79 | | - //Is Grunt Project |
80 | 58 | if (GruntModule.isProject(listFiles)) { |
81 | 59 | GruntModule.executeCommands(file.getName(), file.getPath()); |
82 | 60 | } |
|
0 commit comments