-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.sbt
More file actions
161 lines (148 loc) · 6.19 KB
/
build.sbt
File metadata and controls
161 lines (148 loc) · 6.19 KB
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
lazy val supportedScalaVersions = List("2.13.15", "3.3.4")
ThisBuild / organization := "org.felher"
ThisBuild / organizationName := "Felix Herrmann"
ThisBuild / version := "1.1.0"
ThisBuild / organizationHomepage := Some(url("https://felher.org"))
ThisBuild / scalaVersion := supportedScalaVersions.head
ThisBuild / scmInfo := Some(
ScmInfo(
url("https://github.com/felher/beminar/"),
"scm:git@github.com:felher/beminar.git"
)
)
ThisBuild / developers := List(
Developer(
id = "felher",
name = "Felix Herrmann",
email = "felix@herrmann-koenigsberg.de",
url = url("https://felher.org")
)
)
ThisBuild / description := "A simple BEM utility class for Laminar"
ThisBuild / licenses := List(sbt.librarymanagement.License.MIT)
ThisBuild / homepage := Some(url("https://github.com/felher/beminar/"))
ThisBuild / publishTo := sonatypePublishToBundle.value
ThisBuild / publishMavenStyle := true
lazy val root = project
.in(file("."))
.enablePlugins(ScalaJSPlugin)
.settings(
name := "beminar",
crossScalaVersions := supportedScalaVersions,
usePgpKeyHex("DE132E3B66E5239F490F52AB3DA07E9E7CFDB415"),
Test / publishArtifact := true,
mimaPreviousArtifacts := Set("org.felher" %%% "beminar" % "1.0.0"),
scalacOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((3, _)) =>
Seq(
"-feature",
"-deprecation",
"-Ykind-projector:underscores",
"-Ysafe-init",
"-Xmax-inlines:256",
"-Wunused:all",
"-Wvalue-discard",
"-Wconf:any:verbose",
"-language:implicitConversions"
)
case _ =>
Seq(
"-Xsource:3-cross",
"-encoding",
"utf8",
"-deprecation",
"-feature",
"-unchecked",
"-language:experimental.macros",
"-language:higherKinds",
"-language:implicitConversions",
"-Wvalue-discard",
"-Wunused:implicits",
"-Wunused:explicits",
"-Wunused:imports",
"-Wunused:locals",
"-Wunused:params",
"-Wunused:privates"
)
}),
libraryDependencies ++= Seq(
"org.scala-js" %%% "scalajs-dom" % "2.8.0",
"com.raquo" %%% "laminar" % "17.1.0" % Provided,
"com.lihaoyi" %%% "utest" % "0.8.4" % Test
),
jsEnv := new org.scalajs.jsenv.jsdomnodejs.JSDOMNodeJSEnv(),
testFrameworks += new TestFramework("utest.runner.Framework")
)
lazy val testMatrix = project
.in(file("test-matrix"))
.enablePlugins(ScalaJSPlugin)
.settings(
libraryDependencies ++= Seq(
"com.raquo" %%% "laminar" % "17.1.0",
"org.felher" %%% "beminar" % "1.0.0",
"org.felher" %%% "beminar" % "1.0.0" % Test classifier "tests",
"com.lihaoyi" %%% "utest" % "0.8.4" % Test
),
jsEnv := new org.scalajs.jsenv.jsdomnodejs.JSDOMNodeJSEnv(),
testFrameworks += new TestFramework("utest.runner.Framework"),
commands += Command.command("testLaminarCompatibility") { state =>
final case class CompatTestKey(
scalaVersion: String,
laminarVersion: String,
beminarVersion: String
)
val laminarVersions = List("0.14.5", "15.0.1", "16.0.0", "17.0.0", "17.1.0")
val beminarVersions = List("0.16.0", "1.0.0", "1.1.0")
val scalaVersions = supportedScalaVersions
val allTestKeys = for {
scalaVersion <- scalaVersions
laminarVersion <- laminarVersions
beminarVersion <- beminarVersions
} yield CompatTestKey(scalaVersion, laminarVersion, beminarVersion)
def setVersions(depList: Seq[ModuleID], laminarVersion: String, beminarVersion: String): Seq[ModuleID] =
depList.map(dep => {
if (dep.organization == "com.raquo" && dep.name == "laminar") {
dep.withRevision(laminarVersion)
} else if (dep.organization == "org.felher" && dep.name == "beminar") {
dep.withRevision(beminarVersion)
} else {
dep
}
})
val results = allTestKeys.foldLeft(Map.empty[CompatTestKey, Boolean])((results, testKey) => {
// this code is tricky. The scalajs plugin changes the dependency list depending on the scala version.
// So just adding `scalaVersion := "3.3.4"` to the `newSettings`
// list doesn't work, because the old dependency list is out of date.
//
// Instead of adding a setting, we set the new scala using the `set` command, which seems
// to trigger scalajs updating the dependency list.
val withNewScala = Command.process("set scalaVersion := \"" + testKey.scalaVersion + "\"", state)
val oldDepList = Project.extract(withNewScala).get(libraryDependencies)
val newDepList = setVersions(oldDepList, testKey.laminarVersion, testKey.beminarVersion)
val newSettings = Seq(libraryDependencies := newDepList)
val testState = Project.extract(withNewScala).appendWithSession(newSettings, withNewScala)
val testsOk = Project.runTask(Test / test, testState).fold(false)(_._2.toEither.isRight)
results + (testKey -> testsOk)
})
val header = "||" + beminarVersions.map("Beminar " + _).mkString("|") + "|"
val sepator = "|" + List.fill(beminarVersions.size + 1)("-").mkString("|") + "|"
def makeCell(laminarVersion: String, beminarVersion: String): String = {
val passed = results.filter(entry =>
entry._1.laminarVersion == laminarVersion && entry._1.beminarVersion == beminarVersion && entry._2
)
if (passed.isEmpty) {
"❌"
} else {
"scala " + passed.keys.map(_.scalaVersion).toList.sorted.map(_.replaceAll("\\.\\d+$", "")).mkString(", ")
}
}
def makeRow(laminarVersion: String): String = {
val cells = beminarVersions.map(makeCell(laminarVersion, _))
s"| Laminar $laminarVersion | ${cells.mkString("|")} |"
}
println(header)
println(sepator)
laminarVersions.foreach(laminarVersion => println(makeRow(laminarVersion)))
state
}
)