diff --git a/.gitignore b/.gitignore index 90d43e8..1e63ee2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ *.class *.log +repos project/target target +.idea \ No newline at end of file diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 944681f..0000000 --- a/.gitmodules +++ /dev/null @@ -1,20 +0,0 @@ -[submodule "delphi-webapi"] - path = delphi-webapi - url = https://github.com/delphi-hub/delphi-webapi - branch = . -[submodule "delphi-webapp"] - path = delphi-webapp - url = https://github.com/delphi-hub/delphi-webapp - branch = . -[submodule "delphi-cli"] - path = delphi-cli - url = https://github.com/delphi-hub/delphi-cli - branch = . -[submodule "delphi-crawler"] - path = delphi-crawler - url = https://github.com/delphi-hub/delphi-crawler - branch = . -[submodule "delphi-management"] - path = delphi-management - url = https://github.com/delphi-hub/delphi-management - branch = . \ No newline at end of file diff --git a/LICENSE b/LICENSE index 261eeb9..d7e3293 100644 --- a/LICENSE +++ b/LICENSE @@ -175,18 +175,7 @@ END OF TERMS AND CONDITIONS - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] + Copyright 2018 The Delphi Team (represented by Ben Hermann) Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index ac4e96e..6a6b449 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/build.sbt b/build.sbt index bb3e5f4..4887c5a 100644 --- a/build.sbt +++ b/build.sbt @@ -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") { + 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 + +commands += cloneAll +commands += delete lazy val root = (project in file(".")) - .aggregate(cli, crawler, management, webapi, webapp) + .aggregate(crawler,webapi,cli,management,webapp) +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") diff --git a/delphi-cli b/delphi-cli deleted file mode 160000 index a47de6e..0000000 --- a/delphi-cli +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a47de6eccc8bb8fde058c7c250379a4445a74ba5 diff --git a/delphi-crawler b/delphi-crawler deleted file mode 160000 index a20ae10..0000000 --- a/delphi-crawler +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a20ae10444f10478aa86bfa574e5c98e92a0921a diff --git a/delphi-management b/delphi-management deleted file mode 160000 index 0a25c21..0000000 --- a/delphi-management +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0a25c2146cc49a9e7b8d53de83fb349a060febf1 diff --git a/delphi-webapi b/delphi-webapi deleted file mode 160000 index f07e5d6..0000000 --- a/delphi-webapi +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f07e5d635f40d75c61581792c191632d30bfb5e2 diff --git a/delphi-webapp b/delphi-webapp deleted file mode 160000 index 490efd3..0000000 --- a/delphi-webapp +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 490efd32b7d8c54816339a407437652fba65ffa9 diff --git a/img/delphi.png b/img/delphi.png new file mode 100644 index 0000000..3f6b8ac Binary files /dev/null and b/img/delphi.png differ diff --git a/project/BuildUtils.scala b/project/BuildUtils.scala new file mode 100644 index 0000000..d8a954a --- /dev/null +++ b/project/BuildUtils.scala @@ -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)).! + } + +} \ No newline at end of file diff --git a/project/build.properties b/project/build.properties index 31334bb..d6e3507 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.1.1 +sbt.version=1.1.6 diff --git a/project/plugins.sbt b/project/plugins.sbt index 8edc753..9c47edf 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -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") \ No newline at end of file +addSbtPlugin("com.codacy" % "sbt-codacy-coverage" % "1.3.12") + + +// scalastyle +addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "1.0.0")