Skip to content

Commit 2388795

Browse files
author
Hariharan Ramanathan
committed
Adding build commands to clone pull and run delphi projects
1 parent 8442858 commit 2388795

File tree

5 files changed

+88
-15
lines changed

5 files changed

+88
-15
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
*.class
22
*.log
3+
repos
34
project/target
45
target
6+
.idea

build.sbt

Lines changed: 68 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,85 @@ name := "delphi"
22
version := "1.0.0-SNAPSHOT"
33
scalaVersion := "2.12.4"
44

5+
import sys.process._
6+
import java.io.File
57

68

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
759
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+
968

1069

1170
lazy val cli = Project(
12-
id = "cli",
13-
base = file("delphi-cli"))
71+
id = "cli",
72+
base = file("repos/delphi-cli"))
1473

1574
lazy val crawler = Project(
16-
id = "crawler",
17-
base = file("delphi-crawler"))
75+
id = "crawler",
76+
base = file("repos/delphi-crawler"))
1877

1978
lazy val management = Project(
20-
id = "management",
21-
base = file("delphi-management"))
79+
id = "management",
80+
base = file("repos/delphi-management"))
2281

2382
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"))
3085

3186
addCommandAlias("run", "; all webapi/run crawler/run webapp/run management/run")

project/BuildUtils.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import sys.process._
2+
import java.io._
3+
object BuildUtils {
4+
def pull(repo: String, branch: String) = {
5+
val bash="/bin/bash"
6+
val op="-c"
7+
val checkout=s"git checkout $branch"
8+
val gitPull="git pull"
9+
Process(Seq(bash,op,checkout,gitPull),new File(repo)).!
10+
}
11+
12+
}

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.1.1
1+
sbt.version=1.1.6

project/plugins.sbt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,8 @@ resolvers += "Typesafe Repository" at "https://repo.typesafe.com/typesafe/releas
1414

1515
// coverage
1616
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.1")
17-
addSbtPlugin("com.codacy" % "sbt-codacy-coverage" % "1.3.12")
17+
addSbtPlugin("com.codacy" % "sbt-codacy-coverage" % "1.3.12")
18+
19+
20+
// scalastyle
21+
addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "1.0.0")

0 commit comments

Comments
 (0)