forked from kevin-lee/scala-hedgehog-extra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
184 lines (159 loc) · 6.42 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
import SbtProjectInfo.{ProjectName, commonWarts}
import just.semver.SemVer
ThisBuild / scalaVersion := props.ProjectScalaVersion
ThisBuild / organization := props.Org
ThisBuild / organizationName := "Kevin's Code"
ThisBuild / developers := List(
Developer(
props.GitHubUsername,
"Kevin Lee",
url(s"https://github.com/${props.GitHubUsername}")
)
)
ThisBuild / homepage := Some(url(s"https://github.com/${props.GitHubUsername}/${props.RepoName}"))
ThisBuild / scmInfo :=
Some(
ScmInfo(
url(s"https://github.com/${props.GitHubUsername}/${props.RepoName}"),
s"[email protected]:${props.GitHubUsername}/${props.RepoName}.git",
)
)
ThisBuild / licenses := props.Licenses
ThisBuild / resolvers += "sonatype-snapshots" at s"https://${props.SonatypeCredentialHost}/content/repositories/snapshots"
ThisBuild / testFrameworks ~= (testFws => (TestFramework("hedgehog.sbt.Framework") +: testFws).distinct)
lazy val hedgehogExtra = Project(props.ProjectName, file("."))
.enablePlugins(DevOopsGitHubReleasePlugin)
.settings(
libraryDependencies := removeDottyIncompatible(isScala3(scalaVersion.value), libraryDependencies.value)
)
.settings(mavenCentralPublishSettings)
.settings(noPublish)
.settings(noDoc)
.aggregate(extraCore, extraRefined)
lazy val extraCore = subProject(ProjectName("core"))
.settings(
libraryDependencies := removeDottyIncompatible(isScala3(scalaVersion.value), libraryDependencies.value)
)
lazy val extraRefined = subProject(ProjectName("refined"))
.settings(
libraryDependencies ++= (SemVer.parseUnsafe(scalaVersion.value) match {
case SemVer(SemVer.Major(2), SemVer.Minor(11), _, _, _) =>
Seq("eu.timepit" %% "refined" % "0.9.12" excludeAll ("org.scala-lang.modules" %% "scala-xml"))
case _ =>
Seq("eu.timepit" %% "refined" % "0.9.27" excludeAll ("org.scala-lang.modules" %% "scala-xml"))
}),
libraryDependencies := removeDottyIncompatible(isScala3(scalaVersion.value), libraryDependencies.value)
)
.dependsOn(extraCore)
lazy val props =
new {
val Org = "io.kevinlee"
val GitHubUsername = "Kevin-Lee"
val ProjectName = "hedgehog-extra"
val RepoName = "scala-" + ProjectOrigin
val ProjectScalaVersion = "2.13.6"
// val ProjectScalaVersion = "3.0.0"
val CrossScalaVersions =
Seq(
"2.11.12",
"2.12.13",
"2.13.6",
ProjectScalaVersion
).distinct
val Licenses = List("MIT" -> url("http://opensource.org/licenses/MIT"))
val SonatypeCredentialHost = "s01.oss.sonatype.org"
val SonatypeRepository = s"https://$SonatypeCredentialHost/service/local"
val removeDottyIncompatible: ModuleID => Boolean =
m =>
m.name == "wartremover" ||
m.name == "ammonite" ||
m.name == "kind-projector" ||
m.name == "better-monadic-for" ||
m.name == "mdoc"
val HedgehogVersion = "0.9.0"
val IncludeTest = "compile->compile;test->test"
}
lazy val libs =
new {
lazy val hedgehogLibs = Seq(
"qa.hedgehog" %% "hedgehog-core" % props.HedgehogVersion,
"qa.hedgehog" %% "hedgehog-runner" % props.HedgehogVersion
)
lazy val hedgehogLibsForTesting =
(hedgehogLibs ++ Seq(
"qa.hedgehog" %% "hedgehog-sbt" % props.HedgehogVersion
)).map(_ % Test)
}
def removeDottyIncompatible(isScala3: Boolean, libraries: Seq[ModuleID]): Seq[ModuleID] =
if (isScala3)
libraries.filterNot(props.removeDottyIncompatible).distinct
else
libraries.distinct
lazy val mavenCentralPublishSettings: SettingsDefinition = List(
/* Publish to Maven Central { */
sonatypeCredentialHost := props.SonatypeCredentialHost,
sonatypeRepository := props.SonatypeRepository,
/* } Publish to Maven Central */
)
// format: off
def prefixedProjectName(name: String) = s"${props.ProjectName}${if (name.isEmpty) "" else s"-$name"}"
// format: on
def subProject(projectName: ProjectName): Project = {
val prefixedName = prefixedProjectName(projectName.projectName)
Project(prefixedName, file(s"modules/$prefixedName"))
.settings(
name := prefixedName,
crossScalaVersions := props.CrossScalaVersions,
testFrameworks ~= (testFws => (TestFramework("hedgehog.sbt.Framework") +: testFws).distinct),
libraryDependencies ++= libs.hedgehogLibs ++ libs.hedgehogLibsForTesting,
/* WartRemover and scalacOptions { */
Compile / compile / wartremoverErrors ++= commonWarts((update / scalaBinaryVersion).value),
Test / compile / wartremoverErrors ++= commonWarts((update / scalaBinaryVersion).value),
// wartremoverErrors ++= commonWarts((scalaBinaryVersion in update).value)
// , wartremoverErrors ++= Warts.all
// Compile / console / wartremoverErrors := List.empty,
// Compile / console / wartremoverWarnings := List.empty,
Compile / console / scalacOptions :=
(console / scalacOptions)
.value
.distinct
.filterNot(option => option.contains("wartremover") || option.contains("import")),
// Test / console / wartremoverErrors := List.empty,
// Test / console / wartremoverWarnings := List.empty,
Test / console / scalacOptions :=
(console / scalacOptions)
.value
.distinct
.filterNot(option => option.contains("wartremover") || option.contains("import")),
/* } WartRemover and scalacOptions */
/* Ammonite-REPL { */
libraryDependencies ++=
(scalaBinaryVersion.value match {
case "2.10" =>
Seq.empty[ModuleID]
case "2.11" =>
Seq("com.lihaoyi" % "ammonite" % "1.6.7" % Test cross CrossVersion.full)
case "2.12" | "2.13" | "3" =>
Seq("com.lihaoyi" % "ammonite" % "2.5.3" % Test cross CrossVersion.full)
case _ =>
Seq.empty[ModuleID]
}),
Test / sourceGenerators +=
(scalaBinaryVersion.value match {
case "2.10" | "2.11" =>
task(Seq.empty[File])
case "2.12" | "2.13" | "3" =>
task {
val file = (Test / sourceManaged).value / "amm.scala"
IO.write(file, """object amm extends App { ammonite.AmmoniteMain.main(args) }""")
Seq(file)
}
case _ =>
task(Seq.empty[File])
})
/* } Ammonite-REPL */
)
.settings(mavenCentralPublishSettings)
}
def isScala3(scalaVersion: String): Boolean = scalaVersion.startsWith("3.")