-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
build.sbt
154 lines (140 loc) · 5.43 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
import Settings.stdSettings
import scalapb.compiler.Version.scalapbVersion
val Scala213 = "2.13.15"
val Scala212 = "2.12.20"
val Scala3 = "3.3.4"
publish / skip := true
sonatypeProfileName := "com.thesamet"
def protobufJava = "com.google.protobuf" % "protobuf-java" % "3.25.5"
inThisBuild(
List(
organization := "com.thesamet.scalapb",
homepage := Some(url("https://github.com/scalapb/scalapb-validate")),
licenses := List(
"Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")
),
developers := List(
Developer(
"thesamet",
"Nadav Samet",
"thesamet@gmail.com",
url("https://www.thesamet.com")
)
),
PB.protocVersion := protobufJava.revision
)
)
val pgvVersion = "0.6.13"
val munitSettings = Seq(
libraryDependencies += "org.scalameta" %% "munit" % "1.0.2" % Test,
testFrameworks += new TestFramework("munit.Framework")
)
lazy val core = projectMatrix
.in(file("core"))
.defaultAxes()
.settings(stdSettings)
.settings(munitSettings)
.settings(
name := "scalapb-validate-core",
libraryDependencies ++= Seq(
"com.thesamet.scalapb.common-protos" %% "pgv-proto-scalapb_0.11" % (pgvVersion + "-0"),
"com.thesamet.scalapb.common-protos" %% "pgv-proto-scalapb_0.11" % (pgvVersion + "-0") % "protobuf",
"com.thesamet.scalapb" %% "scalapb-runtime" % scalapbVersion % "protobuf"
),
Compile / PB.targets := Seq(
PB.gens.java -> (Compile / sourceManaged).value / "scalapb",
scalapb.gen() -> (Compile / sourceManaged).value / "scalapb"
),
Compile / packageBin / packageOptions += {
Package.ManifestAttributes(
"ScalaPB-Options-Proto" ->
"scalapb/validate-options.proto"
)
},
compileOrder := CompileOrder.JavaThenScala
)
.jvmPlatform(scalaVersions = Seq(Scala212, Scala213, Scala3))
lazy val cats = projectMatrix
.in(file("cats"))
.dependsOn(core)
.defaultAxes()
.settings(stdSettings)
.settings(munitSettings)
.settings(
name := "scalapb-validate-cats",
libraryDependencies ++= Seq(
"org.typelevel" %% "cats-core" % "2.12.0" % "provided",
"com.thesamet.scalapb" %% "scalapb-runtime" % scalapbVersion % "provided"
)
)
.jvmPlatform(scalaVersions = Seq(Scala212, Scala213, Scala3))
lazy val codeGen = projectMatrix
.in(file("code-gen"))
.defaultAxes()
.enablePlugins(BuildInfoPlugin)
.settings(stdSettings)
.settings(munitSettings)
.settings(
buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion),
buildInfoPackage := "scalapb.validate.compiler",
name := "scalapb-validate-codegen",
libraryDependencies ++= Seq(
protobufJava,
"com.thesamet.scalapb" %% "compilerplugin" % scalapbVersion,
// scalapb-runtime does not gent automatically added since we do not have Scala gen,
// and we want to make sure that a possibly older runtime (with different scalapb.proto)
// gets in through the common-protos dependency.
"com.thesamet.scalapb" %% "scalapb-runtime" % scalapbVersion,
"com.thesamet.scalapb" %% "scalapb-runtime" % scalapbVersion % "protobuf",
"com.thesamet.scalapb.common-protos" %% "pgv-proto-scalapb_0.11" % (pgvVersion + "-0") % "protobuf",
"com.thesamet.scalapb.common-protos" %% "pgv-proto-scalapb_0.11" % (pgvVersion + "-0")
),
Compile / PB.protoSources += core.base / "src" / "main" / "protobuf",
Compile / PB.targets := Seq(
PB.gens.java -> (Compile / sourceManaged).value / "scalapb"
),
compileOrder := CompileOrder.JavaThenScala
)
.jvmPlatform(scalaVersions = Seq(Scala212, Scala213, Scala3))
lazy val codeGenJVM212 = codeGen.jvm(Scala212)
lazy val protocGenScalaPbValidate =
protocGenProject("protoc-gen-scalapb-validate", codeGenJVM212)
.settings(
Compile / mainClass := Some("scalapb.validate.compiler.CodeGenerator")
)
lazy val e2e = projectMatrix
.in(file("e2e"))
.defaultAxes()
.dependsOn(core, cats)
.enablePlugins(LocalCodeGenPlugin)
.settings(stdSettings)
.settings(munitSettings)
.settings(
run / baseDirectory := (LocalRootProject / baseDirectory).value,
run / fork := true,
publish / skip := true,
crossScalaVersions := Seq(Scala212, Scala213),
codeGenClasspath := (codeGenJVM212 / Compile / fullClasspath).value,
libraryDependencies ++= Seq(
"com.thesamet.scalapb" %% "scalapb-json4s" % "0.12.1",
"org.typelevel" %% "cats-core" % "2.12.0",
"io.undertow" % "undertow-core" % "2.3.17.Final",
"eu.timepit" %% "refined" % "0.11.2",
"io.envoyproxy.protoc-gen-validate" % "pgv-java-stub" % pgvVersion % "protobuf"
),
TestProtosGenerator.generateAllTypesProtoSettings,
Compile / PB.protoSources += (Compile / sourceManaged).value / "protobuf",
Compile / PB.protoSources ++= (if (scalaVersion.value.startsWith("2."))
Seq(
(Compile / sourceDirectory).value / "protobuf-scala2"
)
else Seq.empty),
Compile / PB.targets := Seq(
genModule("scalapb.validate.compiler.ValidatePreprocessor$") ->
(Compile / sourceManaged).value / "scalapb",
scalapb.gen(grpc = true) -> (Compile / sourceManaged).value / "scalapb",
genModule("scalapb.validate.compiler.CodeGenerator$") ->
(Compile / sourceManaged).value / "scalapb"
)
)
.jvmPlatform(scalaVersions = Seq(Scala212, Scala213, Scala3))