-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
176 lines (139 loc) · 5.97 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
import scala.language.postfixOps
import scala.sys.process._
import sbt._
name := "rss_brain"
version := "0.1"
scalaVersion := "2.13.10"
enablePlugins(Fs2Grpc)
enablePlugins(Scala2GrpcPlugin)
coverageEnabled := false
coverageExcludedPackages := "me.binwang.rss.grpc.*"
grpcGeneratorMainClass := "me.binwang.rss.grpc.generator.GenerateGRPC"
Compile / scalacOptions += "-Ymacro-annotations"
dependencyCheckAssemblyAnalyzerEnabled := Option(false)
dependencyCheckFailBuildOnCVSS := 4
fork := true
javacOptions ++= Seq("-source", "17", "-target", "17", "-Xlint")
javaOptions += "-Xmx2G"
initialize := {
val _ = initialize.value
val javaVersion = sys.props("java.specification.version")
if (javaVersion != "17")
sys.error("Java 17 is required for this project. Found " + javaVersion + " instead")
}
lazy val doobieVersion = "1.0.0-RC4"
Test / parallelExecution := false
testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-oF")
resolvers += Resolver.bintrayRepo("streamz", "maven") // for streamz
val streamzVersion = "0.13-RC4"
val akkaVersion = "2.8.0"
val esVersion = "8.9.2"
val prometheusVersion = "0.16.0"
val sttpVersion = "3.9.5"
val http4sVersion = "0.23.23"
// do not run generate and validate in the same sbt run since validate will load old resource
lazy val generateRsshubRules = taskKey[Unit]("Generate RSSHub rules")
generateRsshubRules := Def.taskDyn {
val resourceDir = (Compile / resourceDirectory).value
Def.task {
(Compile / runMain).toTask(s" me.binwang.rss.sourcefinder.RsshubRulesConverter $resourceDir/rsshub-regex-rules.json generate").value
}
}.value
lazy val validateRsshubRules = taskKey[Unit]("Validate RSSHub rules")
validateRsshubRules := Def.taskDyn {
val resourceDir = (Compile / resourceDirectory).value
Def.task {
(Compile / runMain).toTask(s" me.binwang.rss.sourcefinder.RsshubRulesConverter $resourceDir/rsshub-regex-rules.json validate").value
}
}.value
lazy val webpack = taskKey[Unit]("Run webpack in js directory")
webpack := {
val workDir = new File("./js")
Process("npm" :: "install" :: Nil, workDir) #&& Process("npx" :: "webpack" :: Nil, workDir) !
}
Compile / resourceGenerators += Def.task {
webpack.value
val file = (Compile / resourceManaged).value / "webview" / "static" / "dist"
IO.copyDirectory(new File("./js/dist"), file, overwrite = true)
IO.listFiles(file).toSeq
}.taskValue
assemblyMergeStrategy in assembly := {
case x if x.endsWith("META-INF/services/io.grpc.LoadBalancerProvider") => MergeStrategy.first
case x if x.endsWith("META-INF/services/io.grpc.NameResolverProvider") => MergeStrategy.first
case PathList("META-INF", xs @ _*) => MergeStrategy.discard
case PathList("module-info.class") => MergeStrategy.discard
case x if x.endsWith("/module-info.class") => MergeStrategy.discard
case x if x.matches("(.+)/protobuf/(\\w+).proto$") => MergeStrategy.discard
case x if x.matches("(.+)/protobuf/(\\w+)/(\\w+).proto$") => MergeStrategy.discard
case x =>
val oldStrategy = (assemblyMergeStrategy in assembly).value
oldStrategy(x)
}
libraryDependencies ++= Seq(
// http client
"com.softwaremill.sttp.client3" %% "circe" % sttpVersion,
"com.softwaremill.sttp.client3" %% "slf4j-backend" % sttpVersion,
"com.softwaremill.sttp.client3" %% "http4s-backend" % sttpVersion,
"io.circe" %% "circe-core" % "0.14.7",
"io.circe" %% "circe-generic" % "0.14.7",
"io.circe" %% "circe-parser" % "0.14.7",
"io.circe" %% "circe-generic-extras" % "0.14.3",
"io.circe" %% "circe-optics" % "0.15.0",
"org.scala-lang.modules" %% "scala-xml" % "2.2.0", // xml parsing
"com.typesafe" % "config" % "1.4.3", // config
"org.jsoup" % "jsoup" % "1.17.2",
"com.sendgrid" % "sendgrid-java" % "4.10.1",
"com.stripe" % "stripe-java" % "26.0.0",
"org.apache.commons" % "commons-text" % "1.11.0",
// redis
"io.lettuce" % "lettuce-core" % "6.2.3.RELEASE",
// database
"org.tpolecat" %% "doobie-core" % doobieVersion,
"org.tpolecat" %% "doobie-postgres" % doobieVersion,
"org.tpolecat" %% "doobie-specs2" % doobieVersion,
"org.tpolecat" %% "doobie-hikari" % doobieVersion,
"io.getquill" %% "quill-doobie" % "4.8.4",
"org.postgresql" % "postgresql" % "42.7.4",
"io.getquill" %% "quill-cassandra-monix" % "4.8.4",
// search
"co.elastic.clients" % "elasticsearch-java" % esVersion,
"com.sksamuel.elastic4s" %% "elastic4s-core" % esVersion,
"com.sksamuel.elastic4s" %% "elastic4s-client-esjava" % esVersion,
"com.sksamuel.elastic4s" %% "elastic4s-json-circe" % esVersion,
"com.sksamuel.elastic4s" %% "elastic4s-effect-cats" % esVersion,
// log
"ch.qos.logback" % "logback-classic" % "1.2.10",
// grpc
"me.binwang.scala2grpc" %% "generator" % "1.0.1",
// http server
"org.http4s" %% "http4s-ember-client" % http4sVersion,
"org.http4s" %% "http4s-ember-server" % http4sVersion,
"org.http4s" %% "http4s-dsl" % http4sVersion,
"org.http4s" %% "http4s-circe" % http4sVersion,
"org.http4s" %% "http4s-prometheus-metrics" % "0.24.6",
"org.http4s" %% "http4s-scalatags" % "0.25.2",
// metrics
"io.prometheus" % "simpleclient" % prometheusVersion,
"io.prometheus" % "simpleclient_hotspot" % prometheusVersion,
"io.prometheus" % "simpleclient_httpserver" % prometheusVersion,
"me.binwang.archmage" %% "core" % "0.1.0-SNAPSHOT",
// throttling
"com.google.guava" % "guava" % "31.1-jre",
"com.bucket4j" % "bucket4j-core" % "8.10.1",
// jwt, jws
"com.nimbusds" % "nimbus-jose-jwt" % "9.39",
"org.bouncycastle" % "bcprov-jdk18on" % "1.78.1",
"org.bouncycastle" % "bcpkix-jdk18on" % "1.78.1",
// testing
"org.scalatest" % "scalatest_2.13" % "3.2.18" % Test,
"org.mock-server" % "mockserver-netty" % "5.15.0" % Test,
"org.scalacheck" %% "scalacheck" % "1.18.0" % Test,
"org.scalamock" %% "scalamock" % "6.0.0" % Test,
)
dependencyOverrides ++= Seq(
"org.slf4j" % "slf4j-api" % "1.7.30", // force use 1.7.X to be compatible
)
excludeDependencies ++= Seq(
ExclusionRule("org.bouncycastle", "bcprov-jdk15on"),
ExclusionRule("org.bouncycastle", "bcpkix-jdk15on"),
)