-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.sbt
118 lines (94 loc) · 4.3 KB
/
build.sbt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import com.typesafe.sbt.packager.MappingsHelper._
import scala.language.postfixOps
import scala.sys.process._
import sbt._
name := """ot-platform-api"""
organization := "io.opentargets"
version := "latest"
lazy val root = (project in file(".")).enablePlugins(PlayScala, PlayLogback)
scalaVersion := "2.13.10"
maintainer := "ops@opentargets.org"
javacOptions ++= Seq("-encoding", "UTF-8")
scalacOptions in ThisBuild ++= Seq(
"-language:_",
"-Xfatal-warnings"
)
scalacOptions in Compile += "-deprecation"
// include resources into the unversal zipped package
mappings in Universal ++= directory(baseDirectory.value / "resources")
resolvers += Resolver.sonatypeRepo("releases")
libraryDependencies ++= Seq(
guice,
caffeine,
"com.typesafe.slick" %% "slick" % "3.4.1",
"org.scalatestplus.play" %% "scalatestplus-play" % "5.1.0" % Test,
"org.scalatestplus" %% "scalacheck-1-15" % "3.2.11.0" % Test
)
val playVersion = "2.8.18"
libraryDependencies += "com.typesafe.play" %% "play" % playVersion
libraryDependencies += "com.typesafe.play" %% "filters-helpers" % playVersion
libraryDependencies += "com.typesafe.play" %% "play-logback" % playVersion
libraryDependencies += "com.typesafe.play" %% "play-json" % "2.9.4"
libraryDependencies += "com.typesafe.play" %% "play-streams" % playVersion
libraryDependencies += "com.typesafe.play" %% "play-slick" % "5.1.0"
val sangriaVersion = "3.5.3"
libraryDependencies += "ru.yandex.clickhouse" % "clickhouse-jdbc" % "0.3.2"
libraryDependencies += "org.sangria-graphql" %% "sangria" % sangriaVersion
libraryDependencies += "org.sangria-graphql" %% "sangria-play-json" % "2.0.2"
libraryDependencies += "com.chuusai" %% "shapeless" % "2.3.10"
lazy val catsVersion = "2.9.0"
lazy val cats = Seq(
"org.typelevel" %% "cats-core" % catsVersion,
"org.typelevel" %% "cats-laws" % catsVersion,
"org.typelevel" %% "cats-kernel" % catsVersion,
"org.typelevel" %% "cats-kernel-laws" % catsVersion
)
libraryDependencies ++= cats
val s4sVersion = "8.5.3"
libraryDependencies ++= Seq(
"com.sksamuel.elastic4s" %% "elastic4s-core" % s4sVersion exclude ("org.slf4j", "slf4j-api"),
"com.sksamuel.elastic4s" %% "elastic4s-client-esjava" % s4sVersion exclude ("org.slf4j", "slf4j-api"),
"com.sksamuel.elastic4s" %% "elastic4s-http-streams" % s4sVersion exclude ("org.slf4j", "slf4j-api"),
"com.sksamuel.elastic4s" %% "elastic4s-json-play" % s4sVersion exclude ("org.slf4j", "slf4j-api")
)
lazy val frontendRepository = settingKey[String]("Git repository with open targets front end.")
lazy val gqlFileDir = settingKey[File]("Location to save test input queries")
lazy val getGqlFiles = taskKey[Unit]("Add *.gql files from frontendRepository to test resources")
lazy val updateGqlFiles = taskKey[Unit]("Report which files are new and which have been updated.")
frontendRepository := "https://github.com/opentargets/ot-ui-apps.git"
gqlFileDir := (Test / resourceDirectory).value / "gqlQueries"
getGqlFiles := {
sbt.IO.withTemporaryDirectory { td =>
// copy files
Process(s"git clone ${frontendRepository.value} ${td.getAbsolutePath}") !
// filter files of interest
val gqlFiles: Seq[File] = (td / "apps/platform/" ** "*.gql").get ++ (td / "packages/sections/" ** "*.gql").get
// delete files in current gql test resources so we can identify when the FE deletes a file
val filesToDelete: Seq[File] =
sbt.IO.listFiles(gqlFileDir.value, NameFilter.fnToNameFilter(!_.contains("full")))
sbt.IO.delete(filesToDelete)
// move files to test resources
sbt.IO.copy(gqlFiles.map(f => (f, gqlFileDir.value / s"${f.getParentFile.name}_${f.name}")))
}
}
updateGqlFiles := {
// trigger update
val a: Unit = getGqlFiles.value
def gitStatusOpt(option: String): Seq[String] =
Process(s"git status -$option ${gqlFileDir.value.getAbsolutePath}").lineStream
.filter(_.contains((Test / resourceDirectory).value.getName))
val newFiles = gitStatusOpt("u")
val updatedFiles = gitStatusOpt("uno")
if (newFiles.nonEmpty) {
println("New files found:")
newFiles.filterNot(f => updatedFiles.contains(f)).foreach(println)
} else {
println("No new files found since last update.")
}
if (updatedFiles.nonEmpty) {
println("Files updated since last refresh:")
updatedFiles.foreach(println)
} else {
println("No existing files have been updated since last check.")
}
}