-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.sbt
238 lines (213 loc) · 10.2 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
import sbt.internal.librarymanagement.mavenint.PomExtraDependencyAttributes.SbtVersionKey
import sbt.internal.librarymanagement.mavenint.PomExtraDependencyAttributes.ScalaVersionKey
import sbtrelease.ReleasePlugin.autoImport.ReleaseTransformations._
import xerial.sbt.Sonatype.autoImport.sonatypeProfileName
ThisBuild / turbo :=true
ThisBuild / classLoaderLayeringStrategy :=ClassLoaderLayeringStrategy.ScalaLibrary
ThisBuild / organization :="io.7mind.izumi.sbt"
ThisBuild / homepage :=Some(url("https://izumi.7mind.io"))
ThisBuild / licenses :=Seq("BSD-style" -> url("http://www.opensource.org/licenses/bsd-license.php"))
ThisBuild / developers :=List(
Developer(id = "7mind", name = "Septimal Mind", url = url("https://github.com/7mind"), email = "team@7mind.io"),
)
ThisBuild / scmInfo :=Some(ScmInfo(url("https://github.com/7mind/sbtgen"), "scm:git:https://github.com/7mind/sbtgen.git"))
(ThisBuild / credentials) ++= {
val f = file(".secrets/credentials.sonatype-nexus.properties")
if (f.exists()) {Seq(Credentials(f))} else {Seq.empty}
}
ThisBuild / publishTo :=(if (!isSnapshot.value) {
sonatypePublishToBundle.value
} else {
Some(Opts.resolver.sonatypeSnapshots)
})
val scalaOpts = scalacOptions ++= ((isSnapshot.value, scalaVersion.value) match {
case (_, ScalaVersions.scala_212) => Seq(
"-Xsource:2.13",
"-Ybackend-parallelism",
"8",
"-explaintypes",
"-Yno-adapted-args",
"-Ypartial-unification",
"-Xlint:adapted-args",
"-Xlint:by-name-right-associative",
"-Xlint:constant",
"-Xlint:delayedinit-select",
"-Xlint:doc-detached",
"-Xlint:inaccessible",
"-Xlint:infer-any",
"-Xlint:missing-interpolator",
"-Xlint:nullary-override",
"-Xlint:nullary-unit",
"-Xlint:option-implicit",
"-Xlint:package-object-classes",
"-Xlint:poly-implicit-overload",
"-Xlint:private-shadow",
"-Xlint:stars-align",
"-Xlint:type-parameter-shadow",
"-Xlint:unsound-match",
"-opt-warnings:_",
"-Ywarn-extra-implicit",
"-Ywarn-unused:_",
"-Ywarn-adapted-args",
"-Ywarn-dead-code",
"-Ywarn-inaccessible",
"-Ywarn-infer-any",
"-Ywarn-nullary-override",
"-Ywarn-nullary-unit",
"-Ywarn-numeric-widen",
"-Ywarn-unused-import",
"-Ywarn-value-discard",
)
case (_, ScalaVersions.scala_213) => Seq(
"-Xsource:2.13",
"-Ybackend-parallelism",
"8",
"-explaintypes",
"-Xlint:_,-missing-interpolator",
"-Wdead-code",
"-Wextra-implicit",
"-Wnumeric-widen",
"-Woctal-literal",
"-Wvalue-discard",
"-Wunused:_",
)
case (_, ScalaVersions.scala_3) => Seq(
"-no-indent",
"-explain",
"-experimental",
)
case (_, _) => Seq.empty
})
lazy val sbtmeta = (project in file("sbtmeta"))
.settings(
crossScalaVersions := Seq(ScalaVersions.scala_3, ScalaVersions.scala_213, ScalaVersions.scala_212),
scalaVersion := crossScalaVersions.value.head,
libraryDependencies ++= {
if (scalaVersion.value.startsWith("2"))
Seq("org.scala-lang" % "scala-reflect" % scalaVersion.value % Provided)
else Seq.empty
},
scalaOpts,
)
lazy val sbtgen = (project in file("sbtgen"))
.dependsOn(sbtmeta)
.settings(
crossScalaVersions := Seq(ScalaVersions.scala_3, ScalaVersions.scala_213, ScalaVersions.scala_212),
scalaVersion := crossScalaVersions.value.head,
libraryDependencies += "com.github.scopt" %% "scopt" % "4.1.0",
libraryDependencies += "org.scala-lang.modules" %% "scala-collection-compat" % "2.12.0",
(ThisBuild / libraryDependencies) += "org.scalatest" %% "scalatest" % "3.2.18" % Test,
scalacOptions ++= Seq(
s"-Xmacro-settings:product-version=${version.value}",
s"-Xmacro-settings:product-group=${organization.value}",
s"-Xmacro-settings:sbt-version=${sbtVersion.value}",
s"-Xmacro-settings:scala-version=${scalaVersion.value}",
s"-Xmacro-settings:scala-versions=${crossScalaVersions.value.mkString(":")}",
s"-Xmacro-settings:scala-js-version=${ScalaVersions.scalaJsVersion}",
s"-Xmacro-settings:scala-native-version=${ScalaVersions.scalaNativeVersion}",
s"-Xmacro-settings:crossproject-version=${Deps.crossProjectVersion}",
s"-Xmacro-settings:bundler-version=${Deps.bundlerVersion}",
s"-Xmacro-settings:sbt-js-dependencies-version=${Deps.sbtJsDependenciesVersion}",
),
scalaOpts,
)
lazy val `sbt-izumi` = (project in file("sbt/sbt-izumi"))
.settings(
crossScalaVersions := Seq(ScalaVersions.scala_212),
scalaVersion := crossScalaVersions.value.head,
crossSbtVersions := Seq(sbtVersion.value),
sbtPlugin := true,
libraryDependencySchemes += "org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always,
libraryDependencies ++= Seq(
"io.get-coursier" %% "coursier" % "2.1.10",
// https://github.com/scoverage/sbt-scoverage
("org.scoverage" % "sbt-scoverage" % "2.0.12").extra(SbtVersionKey -> (pluginCrossBuild / sbtBinaryVersion).value, ScalaVersionKey -> (update / scalaBinaryVersion).value).withCrossVersion(Disabled()),
// http://www.scala-sbt.org/sbt-pgp/
("com.github.sbt" % "sbt-pgp" % "2.2.1").extra(SbtVersionKey -> (pluginCrossBuild / sbtBinaryVersion).value, ScalaVersionKey -> (update / scalaBinaryVersion).value).withCrossVersion(Disabled()),
// https://github.com/sbt/sbt-git
("com.github.sbt" % "sbt-git" % "2.0.1").extra(SbtVersionKey -> (pluginCrossBuild / sbtBinaryVersion).value, ScalaVersionKey -> (update / scalaBinaryVersion).value).withCrossVersion(Disabled()),
// https://github.com/orrsella/sbt-stats
("com.orrsella" % "sbt-stats" % "1.0.7").extra(SbtVersionKey -> (pluginCrossBuild / sbtBinaryVersion).value, ScalaVersionKey -> (update / scalaBinaryVersion).value).withCrossVersion(Disabled()),
// https://github.com/xerial/sbt-sonatype
("org.xerial.sbt" % "sbt-sonatype" % "3.10.0").extra(SbtVersionKey -> (pluginCrossBuild / sbtBinaryVersion).value, ScalaVersionKey -> (update / scalaBinaryVersion).value).withCrossVersion(Disabled()),
// https://github.com/sbt/sbt-release
("com.github.sbt" % "sbt-release" % "1.4.0").extra(SbtVersionKey -> (pluginCrossBuild / sbtBinaryVersion).value, ScalaVersionKey -> (update / scalaBinaryVersion).value).withCrossVersion(Disabled()),
// https://github.com/sbt/sbt-dependency-graph
("org.scala-sbt" % "sbt-dependency-tree" % sbtVersion.value).extra(SbtVersionKey -> (pluginCrossBuild / sbtBinaryVersion).value, ScalaVersionKey -> (update / scalaBinaryVersion).value).withCrossVersion(Disabled()),
// https://github.com/sbt/sbt-duplicates-finder
("com.github.sbt" % "sbt-duplicates-finder" % "1.1.0").extra(SbtVersionKey -> (pluginCrossBuild / sbtBinaryVersion).value, ScalaVersionKey -> (update / scalaBinaryVersion).value).withCrossVersion(Disabled()),
),
libraryDependencies ++= Seq(
("org.scala-js" % "sbt-scalajs" % ScalaVersions.scalaJsVersion % Test).extra(SbtVersionKey -> (pluginCrossBuild / sbtBinaryVersion).value, ScalaVersionKey -> (update / scalaBinaryVersion).value).withCrossVersion(Disabled()),
("org.scala-native" % "sbt-scala-native" % ScalaVersions.scalaNativeVersion % Test).extra(SbtVersionKey -> (pluginCrossBuild / sbtBinaryVersion).value, ScalaVersionKey -> (update / scalaBinaryVersion).value).withCrossVersion(Disabled()),
("org.portable-scala" % "sbt-scalajs-crossproject" % Deps.crossProjectVersion % Test).extra(SbtVersionKey -> (pluginCrossBuild / sbtBinaryVersion).value, ScalaVersionKey -> (update / scalaBinaryVersion).value).withCrossVersion(Disabled()),
("ch.epfl.scala" % "sbt-scalajs-bundler" % Deps.bundlerVersion % Test).extra(SbtVersionKey -> (pluginCrossBuild / sbtBinaryVersion).value, ScalaVersionKey -> (update / scalaBinaryVersion).value).withCrossVersion(Disabled()),
("org.scala-js" % "sbt-jsdependencies" % Deps.sbtJsDependenciesVersion % Test).extra(SbtVersionKey -> (pluginCrossBuild / sbtBinaryVersion).value, ScalaVersionKey -> (update / scalaBinaryVersion).value).withCrossVersion(Disabled()),
),
scalaOpts,
)
lazy val `sbt-tests` = (project in file("sbt/sbt-tests"))
.dependsOn(`sbt-izumi`)
.enablePlugins(ScriptedPlugin)
.settings(
crossSbtVersions := Seq(sbtVersion.value),
crossScalaVersions := Seq(ScalaVersions.scala_212),
scalaVersion := crossScalaVersions.value.head,
sbtPlugin := true,
libraryDependencies ++= Seq(
"org.scala-sbt" % "sbt" % sbtVersion.value
),
publish / skip :=true,
scriptedLaunchOpts := {
Seq(
scriptedLaunchOpts.value,
Seq(
"-Xmx1024M",
"-Dplugin.version=" + version.value,
),
Option(System.getProperty("sbt.ivy.home"))
.toSeq
.flatMap(value => Seq(s"-Dsbt.ivy.home=$value", s"-Divy.home=$value")),
).flatten
},
scriptedBufferLog := false,
scalaOpts,
// Ignore scala-xml version conflict between scoverage where `coursier` requires scala-xml v2
// and scoverage requires scala-xml v1 on Scala 2.12,
// introduced when updating scoverage from 1.9.3 to 2.0.5
libraryDependencySchemes += "org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always
)
lazy val `izumi-sbtgen` = (project in file("."))
.aggregate(
sbtgen,
sbtmeta,
`sbt-izumi`,
)
.settings(
name := "izumi-sbtgen",
scalaVersion := ScalaVersions.scala_212,
crossScalaVersions := Nil,
publish / skip := true,
sonatypeProfileName := "io.7mind",
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies, // : ReleaseStep
inquireVersions, // : ReleaseStep
runClean, // : ReleaseStep
runTest, // : ReleaseStep
runClean, // : ReleaseStep
ReleaseStep(
action = { st: State =>
val extracted = Project.extract(st)
val ref = extracted.get(`sbt-tests` / thisProjectRef)
extracted.runInputTask(ref / (Global / scripted), "", st)._1
}
),
setReleaseVersion, // : ReleaseStep
commitReleaseVersion, // : ReleaseStep, performs the initial git checks
tagRelease, // : ReleaseStep
//publishArtifacts, // : ReleaseStep, checks whether `publishTo` is properly set up
setNextVersion, // : ReleaseStep
commitNextVersion, // : ReleaseStep
pushChanges // : ReleaseStep, also checks that an upstream branch is properly configured
),
)