Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
*.class
*.log
repos
project/target
target
.idea
20 changes: 0 additions & 20 deletions .gitmodules

This file was deleted.

16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,26 @@ This source code repository bundles all of Delphi's components and provides an u
You need a running instance of [ElasticSearch](https://www.elastic.co/downloads/elasticsearch) on your local machine on port 9200.

### Running Delphi locally
After you started ElasticSearch, it is simply a matter of typing
After you started ElasticSearch, you can run delphi by following the below steps

* Cloning the projects. Needs to be done only for the first time.
```
sbt clone-all
```
* After that, just use run command

```
sbt run
```
    
into your terminal. SBT will compile and start all necessary services to run Delphi.

* Delphi components can be deleted in case all cloned components needs to be deleted using

```
sbt delete
```
    
## Components

### delphi-crawler
Expand Down
78 changes: 65 additions & 13 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,82 @@ name := "delphi"
version := "1.0.0-SNAPSHOT"
scalaVersion := "2.12.4"

import sys.process._
import java.io.File


lazy val repos = List("delphi-webapi", "delphi-crawler", "delphi-cli", "delphi-management")
lazy val delphiRepos = "repos"

def cloneAll = Command.command("clone-all") {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clone is not linked to compile scope. Since it is a one time operation

state =>
Process(s"mkdir -p $delphiRepos").!
val currDir = System.getProperty("user.dir")
for (repo <- repos) {
val bash = "/bin/bash"
val op = "-c"
val clone = s"git clone https://github.com/delphi-hub/$repo"
Process(Seq(bash, op, clone), new File(currDir + "/" + delphiRepos)).!
}
state
}





def delete = Command.command("delete") {
state =>
val currDir = System.getProperty("user.dir")
val cmd = "rm -rf " + currDir + "/" + delphiRepos
Process(cmd).!
state
}


lazy val currentBranch = taskKey[String]("Get current git branch")

currentBranch := {
Process("git rev-parse --abbrev-ref HEAD").!!
}


lazy val pull = taskKey[Unit]("Pull Changes")

pull := {
val branch = currentBranch.value
for (repo <- repos) {
BuildUtils.pull(repo, branch)
}

}

Compile / compile := ((Compile / compile) dependsOn pull).value
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The run command by default pull latest changes


commands += cloneAll
commands += delete
lazy val root = (project in file("."))
.aggregate(cli, crawler, management, webapi, webapp)
.aggregate(crawler,webapi,cli,management,webapp)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

repos is directory containing all git components. It is added .gitignore. clone-all command clones the repositories/



lazy val webapi = Project(
id = "webapi",
base = file("repos/delphi-webapi"))

lazy val cli = Project(
id = "cli",
base = file("delphi-cli"))
id = "cli",
base = file("repos/delphi-cli"))

lazy val crawler = Project(
id = "crawler",
base = file("delphi-crawler"))
id = "crawler",
base = file("repos/delphi-crawler"))

lazy val management = Project(
id = "management",
base = file("delphi-management"))
id = "management",
base = file("repos/delphi-management"))

lazy val webapp = Project(
id = "webapp",
base = file("delphi-webapp"))

lazy val webapi = Project(
id = "webapi",
base = file("delphi-webapi"))
id = "webapp",
base = file("repos/delphi-webapp"))

addCommandAlias("run", "; all webapi/run crawler/run webapp/run management/run")
1 change: 0 additions & 1 deletion delphi-cli
Submodule delphi-cli deleted from b9db9d
1 change: 0 additions & 1 deletion delphi-crawler
Submodule delphi-crawler deleted from 2d5de6
1 change: 0 additions & 1 deletion delphi-management
Submodule delphi-management deleted from 2ea123
1 change: 0 additions & 1 deletion delphi-webapi
Submodule delphi-webapi deleted from a65271
1 change: 0 additions & 1 deletion delphi-webapp
Submodule delphi-webapp deleted from 47d678
12 changes: 12 additions & 0 deletions project/BuildUtils.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import sys.process._
import java.io._
object BuildUtils {
def pull(repo: String, branch: String) = {
val bash="/bin/bash"
val op="-c"
val checkout=s"git checkout $branch"
val gitPull="git pull"
Process(Seq(bash,op,checkout,gitPull),new File(repo)).!
}

}
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.1.1
sbt.version=1.1.6
6 changes: 5 additions & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@ resolvers += "Typesafe Repository" at "https://repo.typesafe.com/typesafe/releas

// coverage
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.1")
addSbtPlugin("com.codacy" % "sbt-codacy-coverage" % "1.3.12")
addSbtPlugin("com.codacy" % "sbt-codacy-coverage" % "1.3.12")


// scalastyle
addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "1.0.0")