-
Notifications
You must be signed in to change notification settings - Fork 19
/
build.sbt
309 lines (270 loc) · 11.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
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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
import com.karasiq.scalajsbundler.compilers.{AssetCompilers, ConcatCompiler}
import com.karasiq.scalajsbundler.dsl.Mimes
import sbt.Keys._
import sbtcrossproject.CrossPlugin.autoImport.{CrossType, crossProject}
// Reload on .sbt change
Global / onChangedBuildSource := ReloadOnSourceChanges
// Git versioning
enablePlugins(GitVersioning)
ThisBuild / git.useGitDescribe := true
ThisBuild / git.uncommittedSignifier := None
ThisBuild / versionScheme := Some("pvp")
def _isSnapshotByGit = Def.setting(git.gitCurrentTags.value.isEmpty || git.gitUncommittedChanges.value)
ThisBuild / version := (ThisBuild / version).value + (if (_isSnapshotByGit.value) "-SNAPSHOT" else "")
// -----------------------------------------------------------------------
// Versions
// -----------------------------------------------------------------------
val ScalaTagsVersion = "0.11.0"
val ScalaRxVersion = if (ProjectDefs.scalaJSIs06) "0.4.1" else "0.4.3"
val ScalaJsDomVersion = if (ProjectDefs.scalaJSIs06) "1.0.0" else "2.0.0"
val ScalaJSJQueryVersion = if (ProjectDefs.scalaJSIs06) "3.0.1" else "3.2.0"
// -----------------------------------------------------------------------
// Settings
// -----------------------------------------------------------------------
lazy val commonSettings = Seq(
scalaVersion := (if (ProjectDefs.scalaJSIs06) "2.13.4" else "2.13.7"),
crossScalaVersions := {
if (ProjectDefs.scalaJSIs06) Seq("2.11.12", "2.12.12", scalaVersion.value)
else Seq("2.12.12", scalaVersion.value)
},
organization := "com.github.karasiq"
)
lazy val publishSettings = Seq(
publishMavenStyle := true,
sonatypeSessionName := s"scalajs-bootstrap v${version.value}",
publishConfiguration := publishConfiguration.value.withOverwrite(true),
publishTo := sonatypePublishToBundle.value,
Test / publishArtifact := false,
pomIncludeRepository := { _ ⇒ false },
licenses := Seq("The MIT License" → url("http://opensource.org/licenses/MIT")),
homepage := Some(url("https://github.com/Karasiq/scalajs-bootstrap")),
scmInfo := Some(
ScmInfo(
new URL("https://github.com/Karasiq/scalajs-bootstrap"),
"scm:git:[email protected]:Karasiq/scalajs-bootstrap.git"
)
),
developers := List(
Developer(
"Karasiq",
"Piston Karasiq",
new URL("https://github.com/Karasiq")
)
)
)
lazy val noPublishSettings = Seq(
publishArtifact := false,
makePom / publishArtifact := false,
publishTo := Some(Resolver.file("Repo", file("target/repo")))
)
// -----------------------------------------------------------------------
// Context library
// -----------------------------------------------------------------------
lazy val contextLibrary = (crossProject(JSPlatform, JVMPlatform) in file("context"))
.settings(
commonSettings,
publishSettings,
name := "scalajs-bootstrap-context",
libraryDependencies ++= Seq(
"com.lihaoyi" %%% "scalatags" % ScalaTagsVersion
),
libraryDependencies ++= (scalaBinaryVersion.value match {
case "2.11" ⇒
Seq(
"com.lihaoyi" %%% "scalarx" % "0.4.0"
)
case _ ⇒
Seq(
"com.lihaoyi" %%% "scalarx" % ScalaRxVersion
)
})
)
lazy val contextLibraryJS = contextLibrary.js
lazy val contextLibraryJVM = contextLibrary.jvm
// -----------------------------------------------------------------------
// JQuery library
// -----------------------------------------------------------------------
lazy val jsLibrarySettings = Seq(
libraryDependencies ++= (scalaBinaryVersion.value match {
case "2.11" ⇒
Seq(
"io.udash" %%% "udash-jquery" % "3.0.1",
"org.scala-js" %%% "scalajs-dom" % ScalaJsDomVersion
)
case _ if ProjectDefs.scalaJSIs06 ⇒
Seq(
"io.udash" %%% "udash-jquery" % "3.0.2",
"org.scala-js" %%% "scalajs-dom" % ScalaJsDomVersion
)
case _ ⇒
Seq(
"io.udash" %%% "udash-jquery" % ScalaJSJQueryVersion,
"org.scala-js" %%% "scalajs-dom" % ScalaJsDomVersion
)
}),
/* scalacOptions += {
val local = file("").toURI
val remote = s"https://raw.githubusercontent.com/Karasiq/scalajs-bootstrap/${git.gitHeadCommit.value.get}/"
s"-P:scalajs:mapSourceURI:$local->$remote"
},*/
Compile / webpackEmitSourceMaps := true,
// Compile / webpack / version := "5.74.0",
Compile / npmExtraArgs += "--legacy-peer-deps"
)
lazy val jQueryLibrary = (project in file("jquery"))
.settings(
commonSettings,
jsLibrarySettings,
publishSettings,
name := "scalajs-bootstrap-jquery"
)
.enablePlugins(scalajsbundler.sbtplugin.ScalaJSBundlerPlugin)
// -----------------------------------------------------------------------
// Library
// -----------------------------------------------------------------------
lazy val library = crossProject(JSPlatform, JVMPlatform)
.settings(commonSettings, publishSettings, name := "scalajs-bootstrap")
.jsSettings(
jsLibrarySettings,
Compile / npmDependencies += "bootstrap" → "^3.4.1"
)
.dependsOn(contextLibrary)
lazy val libraryJS = library.js
.dependsOn(jQueryLibrary)
.enablePlugins(scalajsbundler.sbtplugin.ScalaJSBundlerPlugin)
lazy val libraryJVM = library.jvm
lazy val libraryV4 = (crossProject(JSPlatform, JVMPlatform) in file("library-v4"))
.settings(commonSettings, publishSettings, name := "scalajs-bootstrap-v4")
.jsSettings(
jsLibrarySettings,
Compile / npmDependencies ++= Seq(
"bootstrap" → "^4.5.3"
)
)
.dependsOn(contextLibrary)
lazy val libraryV4JS = libraryV4.js
.dependsOn(jQueryLibrary)
.enablePlugins(scalajsbundler.sbtplugin.ScalaJSBundlerPlugin)
lazy val libraryV4JVM = libraryV4.jvm
// -----------------------------------------------------------------------
// Test page
// -----------------------------------------------------------------------
lazy val testPageSettings = Seq(
scalaJSUseMainModuleInitializer := true,
name := "scalajs-bootstrap-test-frontend",
Compile / npmDevDependencies ++= Seq(
"webpack-merge" → "~4.2.2",
"imports-loader" → "~0.8.0",
"expose-loader" → "~0.7.5"
),
webpackConfigFile := Some(baseDirectory.value / "webpack.config.js"),
Compile / npmExtraArgs += "--legacy-peer-deps"
)
lazy val testPageV4Settings = Seq(
scalaJSUseMainModuleInitializer := true,
name := "scalajs-bootstrap-test-frontend-v4",
Compile / npmExtraArgs += "--legacy-peer-deps"
)
lazy val testShared = (crossProject(JSPlatform, JVMPlatform).crossType(CrossType.Pure) in file("test") / "shared")
.settings(commonSettings, noPublishSettings, name := "scalajs-bootstrap-test-shared")
.dependsOn(library)
lazy val testSharedJS = testShared.js
lazy val testSharedJVM = testShared.jvm
lazy val testSharedV4 = (crossProject(JSPlatform, JVMPlatform).crossType(CrossType.Pure) in file("test") / "shared-v4")
.settings(commonSettings, noPublishSettings, name := "scalajs-bootstrap-test-shared-v4")
.dependsOn(libraryV4)
lazy val testSharedV4JS = testSharedV4.js
lazy val testSharedV4JVM = testSharedV4.jvm
lazy val testPage = (project in (file("test") / "frontend"))
.settings(commonSettings, jsLibrarySettings, testPageSettings, noPublishSettings)
.enablePlugins(scalajsbundler.sbtplugin.ScalaJSBundlerPlugin)
.dependsOn(testSharedJS)
lazy val testPageV4 = (project in (file("test") / "frontend-v4"))
.settings(commonSettings, jsLibrarySettings, testPageV4Settings, noPublishSettings)
.enablePlugins(scalajsbundler.sbtplugin.ScalaJSBundlerPlugin)
.dependsOn(testSharedV4JS)
// -----------------------------------------------------------------------
// Test server
// -----------------------------------------------------------------------
lazy val testServerSettings = Seq(
scalaVersion := "2.13.7",
name := "scalajs-bootstrap-test",
resolvers ++= Resolver.sonatypeOssRepos("snapshots"),
libraryDependencies ++= {
val akkaV = "2.6.18"
val akkaHttpV = "10.2.7"
Seq(
"com.typesafe.akka" %% "akka-actor-typed" % akkaV,
"com.typesafe.akka" %% "akka-stream" % akkaV,
"com.typesafe.akka" %% "akka-http" % akkaHttpV
)
},
clean := clean.dependsOn(testPage / clean, testPageV4 / clean).value
) ++ inConfig(Compile)(
Seq(
mainClass := Some("com.karasiq.bootstrap.test.backend.BootstrapTestApp"),
compile := compile.dependsOn(scalaJsBundlerCompile).value,
scalaJsBundlerInline := false,
scalaJsBundlerCompile := {
val result = scalaJsBundlerCompile
.dependsOn(testPage / Compile / fastOptJS / webpack, testPageV4 / Compile / fastOptJS / webpack)
.value
result
},
scalaJsBundlerAssets ++= {
import com.karasiq.scalajsbundler.dsl._
// val jQuery = Seq(Script from url("https://code.jquery.com/jquery-3.2.1.js"))
val bootstrap3 = Seq(
Style from url("https://raw.githubusercontent.com/twbs/bootstrap/v3.3.7/dist/css/bootstrap.css")
// Script from url("https://raw.githubusercontent.com/twbs/bootstrap/v3.3.7/dist/js/bootstrap.js")
)
val bootstrap4 = Seq(
Style from url("https://raw.githubusercontent.com/twbs/bootstrap/v4.1.1/dist/css/bootstrap.css")
// Script from url("https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.6/popper.min.js"),
// Script from url("https://raw.githubusercontent.com/twbs/bootstrap/v4.1.1/dist/js/bootstrap.bundle.js")
)
val fonts =
Seq(Style from url("https://raw.githubusercontent.com/FortAwesome/Font-Awesome/v4.5.0/css/font-awesome.css")) ++
fontPackage(
"glyphicons-halflings-regular",
"https://raw.githubusercontent.com/twbs/bootstrap/v3.3.6/dist/fonts/glyphicons-halflings-regular"
) ++
fontPackage(
"fontawesome-webfont",
"https://raw.githubusercontent.com/FortAwesome/Font-Awesome/v4.5.0/fonts/fontawesome-webfont"
)
Seq(
Bundle(
"index",
bootstrap3,
Html from TestPageAssets.index,
Style from TestPageAssets.style,
fonts,
scalaJsBundlerApplication(testPage, fastOpt = true).value,
TestPageAssets.sourceMap(testPage, fastOpt = true).value
),
Bundle(
"index-v4",
bootstrap4,
Html from TestPageAssets.index, /* Style from TestPageAssets.style, */ fonts,
scalaJsBundlerApplication(testPageV4, fastOpt = true).value,
TestPageAssets.sourceMap(testPageV4, fastOpt = true).value
)
)
},
Compile / scalaJsBundlerCompilers := AssetCompilers { case Mimes.javascript ⇒
ConcatCompiler
}.<<=(AssetCompilers.default)
)
)
lazy val testServer = (project in file("test"))
.settings(testServerSettings, noPublishSettings)
.dependsOn(testSharedJVM)
.enablePlugins(SJSAssetBundlerPlugin)
// -----------------------------------------------------------------------
// Misc
// -----------------------------------------------------------------------
lazy val `scalajs-bootstrap` = (project in file("."))
.settings(commonSettings, noPublishSettings)
.aggregate(contextLibraryJS, contextLibraryJVM, jQueryLibrary, libraryJS, libraryJVM, libraryV4JS, libraryV4JVM)