@@ -2,30 +2,85 @@ name := "delphi"
2
2
version := " 1.0.0-SNAPSHOT"
3
3
scalaVersion := " 2.12.4"
4
4
5
+ import sys .process ._
6
+ import java .io .File
5
7
6
8
9
+ lazy val repos = List (" delphi-webapi" , " delphi-crawler" , " delphi-cli" , " delphi-management" )
10
+ lazy val delphiRepos = " repos"
11
+
12
+ def cloneAll = Command .command(" clone-all" ) {
13
+ state =>
14
+ Process (s " mkdir -p $delphiRepos" ).!
15
+ val currDir = System .getProperty(" user.dir" )
16
+ for (repo <- repos) {
17
+ val bash = " /bin/bash"
18
+ val op = " -c"
19
+ val clone = s " git clone https://github.com/delphi-hub/ $repo"
20
+ Process (Seq (bash, op, clone), new File (currDir + " /" + delphiRepos)).!
21
+ }
22
+ state
23
+ }
24
+
25
+
26
+
27
+
28
+
29
+ def delete = Command .command(" delete" ) {
30
+ state =>
31
+ val currDir = System .getProperty(" user.dir" )
32
+ val cmd = " rm -rf " + currDir + " /" + delphiRepos
33
+ Process (cmd).!
34
+ state
35
+ }
36
+
37
+
38
+ lazy val currentBranch = taskKey[String ](" Get current git branch" )
39
+
40
+ currentBranch := {
41
+ Process (" git rev-parse --abbrev-ref HEAD" ).!!
42
+ }
43
+
44
+
45
+ lazy val pull = taskKey[Unit ](" Pull Changes" )
46
+
47
+ pull := {
48
+ val branch = currentBranch.value
49
+ for (repo <- repos) {
50
+ BuildUtils .pull(repo, branch)
51
+ }
52
+
53
+ }
54
+
55
+ Compile / compile := ((Compile / compile) dependsOn pull).value
56
+
57
+ commands += cloneAll
58
+ commands += delete
7
59
lazy val root = (project in file(" ." ))
8
- .aggregate(cli, crawler, management, webapi, webapp)
60
+ .aggregate(crawler,webapi,cli,management,webapp)
61
+
62
+
63
+ lazy val webapi = Project (
64
+ id = " webapi" ,
65
+ base = file(" repos/delphi-webapi" ))
66
+
67
+
9
68
10
69
11
70
lazy val cli = Project (
12
- id = " cli" ,
13
- base = file(" delphi-cli" ))
71
+ id = " cli" ,
72
+ base = file(" repos/ delphi-cli" ))
14
73
15
74
lazy val crawler = Project (
16
- id = " crawler" ,
17
- base = file(" delphi-crawler" ))
75
+ id = " crawler" ,
76
+ base = file(" repos/ delphi-crawler" ))
18
77
19
78
lazy val management = Project (
20
- id = " management" ,
21
- base = file(" delphi-management" ))
79
+ id = " management" ,
80
+ base = file(" repos/ delphi-management" ))
22
81
23
82
lazy val webapp = Project (
24
- id = " webapp" ,
25
- base = file(" delphi-webapp" ))
26
-
27
- lazy val webapi = Project (
28
- id = " webapi" ,
29
- base = file(" delphi-webapi" ))
83
+ id = " webapp" ,
84
+ base = file(" repos/delphi-webapp" ))
30
85
31
86
addCommandAlias(" run" , " ; all webapi/run crawler/run webapp/run management/run" )
0 commit comments