forked from zio/zio-config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
263 lines (234 loc) · 8.71 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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
import BuildHelper._
inThisBuild(
List(
organization := "dev.zio",
homepage := Some(url("https://zio.github.io/zio-config/")),
licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
developers := List(
Developer(
"afsalthaj",
"Afsal Thaj",
"https://medium.com/@afsal.taj06",
url("https://github.com/afsalthaj")
),
Developer(
"jdegoes",
"John De Goes",
url("http://degoes.net")
)
),
pgpPassphrase := sys.env.get("PGP_PASSWORD").map(_.toArray),
pgpPublicRing := file("/tmp/public.asc"),
pgpSecretRing := file("/tmp/secret.asc"),
scmInfo := Some(
ScmInfo(url("https://github.com/zio/zio-config/"), "scm:git:[email protected]:zio/zio-config.git")
)
)
)
ThisBuild / publishTo := sonatypePublishToBundle.value
lazy val createProductBuilder = taskKey[Unit]("Generate code for ProductBuilder.scala")
createProductBuilder := {
val productBuilderFile = (sourceDirectory in zioConfig).value / "main" / "scala" / "zio" / "config" / "ProductBuilder.scala"
val resource = (resourceManaged in Compile).value / "scalaFmt" / "temporary"
val scalaFmt = baseDirectory.value / ".scalafmt.conf"
ProductBuilderCodeGen.replaceFileSection(
productBuilderFile,
"productbuilder",
ProductBuilderCodeGen.productBuilderCodes :+ "",
resource,
scalaFmt
)
}
addCommandAlias("fmt", "; scalafmtSbt; scalafmt; test:scalafmt")
addCommandAlias("check", "; scalafmtSbtCheck; scalafmtCheck; test:scalafmtCheck")
addCommandAlias(
"checkAll",
"; ++2.11.12; project root2-11; check; ++2.12.11; project root2-12; check; ++2.13.2; project root2-13; check"
)
addCommandAlias("compileAll", "; ++2.11.12; root2-11/compile; ++2.12.11; root2-12/compile; ++2.13.2!; root2-13/compile")
addCommandAlias("testAll", "; ++2.11.12; root2-11/test; ++2.12.11; root2-12/test; ++2.13.2!; root2-13/test")
lazy val zioVersion = "1.0.5"
lazy val magnoliaVersion = "0.17.0"
lazy val refinedVersion = "0.9.14"
lazy val shapelessVersion = "2.4.0-M1"
lazy val magnoliaDependencies =
libraryDependencies ++= {
if (scalaBinaryVersion.value == "2.11") Seq.empty // Just to make IntelliJ happy
else
Seq(
"com.propensive" %% "magnolia" % magnoliaVersion,
"org.scala-lang" % "scala-reflect" % scalaVersion.value
)
}
lazy val refinedDependencies =
libraryDependencies ++= {
if (scalaBinaryVersion.value == "2.11") Seq.empty // Just to make IntelliJ happy
else Seq("eu.timepit" %% "refined" % refinedVersion)
}
lazy val scala211projects =
Seq[ProjectReference](zioConfig, zioConfigTypesafe, zioConfigShapeless, zioConfigDerivation, zioConfigYaml)
lazy val scala212projects = scala211projects ++ Seq[ProjectReference](
zioConfigGen,
zioConfigRefined,
zioConfigMagnolia,
examples,
zioConfigTypesafeMagnoliaTests
)
lazy val scala213projects = scala212projects
lazy val root =
project
.in(file("."))
.settings(skip in publish := true)
.aggregate(scala211projects: _*)
lazy val `root2-11` =
project
.in(file("2-11"))
.settings(skip in publish := true)
.aggregate(scala211projects: _*)
lazy val `root2-12` =
project
.in(file("2-12"))
.settings(skip in publish := true)
.aggregate(scala212projects: _*)
lazy val `root2-13` =
project
.in(file("2-13"))
.settings(skip in publish := true)
.aggregate(scala213projects: _*)
lazy val zioConfig =
module("zio-config", "core")
.enablePlugins(BuildInfoPlugin)
.settings(buildInfoSettings)
.settings(
libraryDependencies ++= Seq(
"dev.zio" %% "zio-test" % zioVersion % Test,
"dev.zio" %% "zio-test-sbt" % zioVersion % Test
),
testFrameworks := Seq(new TestFramework("zio.test.sbt.ZTestFramework")),
scalacOptions += "-P:silencer:lineContentFilters=import VersionSpecificSupport\\._"
)
lazy val zioConfigRefined =
module("zio-config-refined", "refined")
.settings(
refinedDependencies,
libraryDependencies ++=
Seq(
"dev.zio" %% "zio-test" % zioVersion % Test,
"dev.zio" %% "zio-test-sbt" % zioVersion % Test
),
testFrameworks := Seq(new TestFramework("zio.test.sbt.ZTestFramework")),
scalacOptions += "-P:silencer:lineContentFilters=import VersionSpecificSupport\\._"
)
.dependsOn(zioConfigMagnolia % "compile->compile;test->test")
lazy val runAllExamples = taskKey[Unit]("Run all main classes in examples module")
lazy val examples = module("zio-config-examples", "examples")
.settings(
skip in publish := true,
fork := true,
magnoliaDependencies,
refinedDependencies,
runAllExamples :=
Def
.taskDyn({
val c = (discoveredMainClasses in Compile).value
val runs = (runMain in Compile)
val x = c.map(cc => {
Def.task {
runs.toTask(s" ${cc}").value
}
})
Def.sequential(x)
})
.value
)
.dependsOn(zioConfig, zioConfigMagnolia, zioConfigRefined, zioConfigTypesafe, zioConfigGen)
lazy val zioConfigDerivation = module("zio-config-derivation", "derivation")
.dependsOn(zioConfig)
lazy val zioConfigGen = module("zio-config-gen", "gen")
.settings(
magnoliaDependencies,
libraryDependencies ++= Seq(
"dev.zio" %% "zio-test-magnolia" % zioVersion,
"org.scalatest" %% "scalatest" % "3.2.3" % Test
)
)
.dependsOn(zioConfigTypesafe, zioConfigMagnolia)
lazy val zioConfigMagnolia = module("zio-config-magnolia", "magnolia")
.settings(
magnoliaDependencies,
libraryDependencies ++= Seq(
"dev.zio" %% "zio-test" % zioVersion % Test,
"dev.zio" %% "zio-test-sbt" % zioVersion % Test
),
testFrameworks := Seq(new TestFramework("zio.test.sbt.ZTestFramework"))
)
.dependsOn(zioConfig % "compile->compile;test->test", zioConfigDerivation)
lazy val zioConfigShapeless = module("zio-config-shapeless", "shapeless")
.settings(
libraryDependencies ++= Seq(
"dev.zio" %% "zio-test" % zioVersion % Test,
"dev.zio" %% "zio-test-sbt" % zioVersion % Test,
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"com.chuusai" %% "shapeless" % shapelessVersion
),
testFrameworks := Seq(new TestFramework("zio.test.sbt.ZTestFramework"))
)
.dependsOn(zioConfig % "compile->compile;test->test", zioConfigDerivation)
lazy val zioConfigTypesafe =
module("zio-config-typesafe", "typesafe")
.settings(
libraryDependencies ++= Seq(
"com.typesafe" % "config" % "1.4.1",
"dev.zio" %% "zio-test" % zioVersion % Test,
"dev.zio" %% "zio-test-sbt" % zioVersion % Test
),
testFrameworks := Seq(new TestFramework("zio.test.sbt.ZTestFramework")),
scalacOptions += "-P:silencer:lineContentFilters=import VersionSpecificSupport\\._"
)
.dependsOn(zioConfig % "compile->compile;test->test")
lazy val zioConfigYaml =
module("zio-config-yaml", "yaml")
.settings(
libraryDependencies ++= Seq(
"org.snakeyaml" % "snakeyaml-engine" % "2.2.1",
"dev.zio" %% "zio-test" % zioVersion % Test,
"dev.zio" %% "zio-test-sbt" % zioVersion % Test
),
testFrameworks := Seq(new TestFramework("zio.test.sbt.ZTestFramework")),
scalacOptions += "-P:silencer:lineContentFilters=import VersionSpecificSupport\\._"
)
.dependsOn(zioConfig % "compile->compile;test->test")
lazy val zioConfigTypesafeMagnoliaTests =
module("zio-config-typesafe-magnolia-tests", "typesafe-magnolia-tests")
.settings(
skip in publish := true,
libraryDependencies ++= Seq(
"com.typesafe" % "config" % "1.4.1",
"dev.zio" %% "zio-test" % zioVersion % Test,
"dev.zio" %% "zio-test-sbt" % zioVersion % Test
),
testFrameworks := Seq(new TestFramework("zio.test.sbt.ZTestFramework"))
)
.dependsOn(zioConfig % "compile->compile;test->test", zioConfigTypesafe, zioConfigMagnolia)
def module(moduleName: String, fileName: String): Project =
Project(moduleName, file(fileName))
.settings(stdSettings(moduleName))
.settings(
libraryDependencies ++= Seq(
"dev.zio" %% "zio" % zioVersion
)
)
lazy val docs = project
.in(file("zio-config-docs"))
.settings(
skip in publish := true,
moduleName := "zio-config-docs",
scalacOptions -= "-Yno-imports",
scalacOptions -= "-Xfatal-warnings",
magnoliaDependencies,
refinedDependencies,
libraryDependencies += "dev.zio" %% "zio" % zioVersion
)
.dependsOn(zioConfig, zioConfigMagnolia, zioConfigTypesafe, zioConfigRefined, zioConfigGen)
.enablePlugins(MdocPlugin, DocusaurusPlugin)