-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathbuild.sbt
96 lines (91 loc) · 3.35 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
import sbt.CrossVersion
lazy val scala212 = "2.12.18"
lazy val scala213 = "2.13.14"
lazy val scala3LTS = "3.3.4"
lazy val scala3 = "3.6.3"
lazy val commonSettings = List(
scalaVersion := scala212,
scalacOptions ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, _)) => scalacOptions ++= Seq("-Xlint")
case _ => ()
}
Seq(
"-encoding",
"utf8",
"-deprecation",
"-unchecked",
"-Xfatal-warnings"
)
},
Compile / console / scalacOptions --= Seq("-deprecation", "-Xfatal-warnings", "-Xlint"),
scalafmtOnCompile := true
)
lazy val codegen = (project in file("codegen"))
.enablePlugins(SbtPlugin, BuildInfoPlugin)
.settings(
commonSettings,
name := "twinagle-scalapb-plugin",
addSbtPlugin("com.thesamet" % "sbt-protoc" % "1.0.7"),
libraryDependencies += "com.thesamet.scalapb" %% "compilerplugin" % scalapb.compiler.Version.scalapbVersion,
buildInfoKeys := Seq[BuildInfoKey](version, scalaBinaryVersion),
buildInfoPackage := "com.soundcloud.twinagle.codegen",
buildInfoUsePackageAsPath := true,
publishLocal := publishLocal.dependsOn(runtime / publishLocal).value,
scriptedLaunchOpts ++= Seq("-Xmx1024M", "-Dplugin.version=" + version.value),
scriptedBufferLog := false
)
lazy val runtime = (project in file("runtime")).settings(
commonSettings,
name := "twinagle-runtime",
crossScalaVersions := Seq(scala212, scala213, scala3LTS, scala3),
// finagle uses 2.13 heavily so we will ignore our project runtime compat
excludeDependencies += "org.scala-lang.modules" % "scala-collection-compat_3",
libraryDependencies ++= {
Seq(
"com.twitter" %% "finagle-http" % "24.2.0" cross CrossVersion.for3Use2_13,
"com.thesamet.scalapb" %% "scalapb-runtime" % "0.11.17",
"com.thesamet.scalapb" %% "scalapb-json4s" % "0.12.1",
"org.json4s" %% "json4s-native" % "4.0.7",
"org.specs2" %% "specs2-core" % "4.20.8" % Test cross CrossVersion.for3Use2_13
)
},
libraryDependencies ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 13)) | Some((2, 12)) =>
Seq(
"org.specs2" %% "specs2-mock" % "4.20.8" % Test
)
case Some((3, 3)) =>
Seq(
"org.scalamock" %% "scalamock" % "6.1.1" % Test
)
case Some((3, _)) =>
Seq(
"org.scalamock" %% "scalamock" % "7.1.0" % Test
)
case _ => Seq.empty
}
},
// compile protobuf messages for unit tests
Project.inConfig(Test)(sbtprotoc.ProtocPlugin.protobufConfigSettings),
Test / scalacOptions += {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((3, minor)) if minor > 3 => "-experimental"
case _ => ""
}
},
Test / PB.targets := {
val gen3 = CrossVersion.partialVersion(scalaVersion.value).exists(a => a._1 == 3L)
Seq(
scalapb.gen(flatPackage = true, scala3Sources = gen3) -> (Test / sourceManaged).value
)
}
)
lazy val root = (project in file("."))
.aggregate(runtime, codegen)
.settings(
name := "twinagle-root",
resolvers += Resolver.typesafeIvyRepo("releases"),
publish / skip := true
)