forked from sherpal/LaminarSAPUI5Bindings
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
134 lines (116 loc) · 3.92 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
import java.nio.charset.StandardCharsets
ThisBuild / scalaVersion := "3.3.1"
val usedScalacOptions = Def.task {
Seq(
"-encoding",
"utf8",
"-Xfatal-warnings",
"-deprecation",
"-unchecked",
"-language:higherKinds",
"-feature",
"-language:implicitConversions"
)
}
val withSourceMaps = Def.task {
val localSourcesPath = (LocalRootProject / baseDirectory).value.toURI.toString
val remoteSourcesPath =
s"https://raw.githubusercontent.com/sherpal/LaminarSAPUI5Bindings/${git.gitHeadCommit.value.get}/"
val sourcesOptionName =
if (scalaVersion.value.startsWith("2.")) "-P:scalajs:mapSourceURI" else "-scalajs-mapSourceURI"
Seq(s"${sourcesOptionName}:$localSourcesPath->$remoteSourcesPath") ++ usedScalacOptions.value
}
val laminarVersion = "17.0.0"
inThisBuild(
List(
name := "web-components-ui5",
organization := "be.doeraene",
description := "Laminar bindings for the web-component library UI5 from SAP",
homepage := Some(url("https://github.com/sherpal/LaminarSAPUI5Bindings")),
licenses := List("MIT" -> url("http://www.opensource.org/licenses/mit-license.php")),
developers := List(
Developer(
"sherpal",
"Antoine Doeraene",
url("https://github.com/sherpal")
)
)
)
)
lazy val `web-components-ui5` = project
.in(file("./web-components"))
.enablePlugins(ScalaJSPlugin)
.settings(name := "web-components-ui5")
.settings(
scalacOptions ++= withSourceMaps.value,
scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule)),
libraryDependencies ++= List("com.raquo" %%% "laminar" % laminarVersion % Provided),
Compile / doc := new java.io.File("no-doc")
)
// We need this dummy root for the publishing
lazy val root = project
.in(file("."))
.aggregate(`web-components-ui5`)
.settings(
publish / skip := true
)
lazy val demo = project
.in(file("./demo"))
.enablePlugins(ScalaJSPlugin)
.enablePlugins(BundleMonPlugin)
.settings(
scalacOptions ++= withSourceMaps.value,
libraryDependencies ++= List(
"com.raquo" %%% "laminar" % laminarVersion
),
scalaJSLinkerConfig ~= { _.withModuleKind(ModuleKind.ESModule) },
scalaJSUseMainModuleInitializer := true,
publish / skip := true
)
.dependsOn(`web-components-ui5`)
Global / onLoad := {
val scalaVersionValue = (demo / scalaVersion).value
val outputFile = baseDirectory.value / "demo" / "scala-metadata.js"
IO.writeLines(
outputFile,
s"""
|const scalaVersion = "$scalaVersionValue"
|
|exports.scalaMetadata = {
| scalaVersion: scalaVersion
|}
|""".stripMargin.split("\n").toList,
StandardCharsets.UTF_8
)
(Global / onLoad).value
}
val configKeyFolder =
os.pwd / "web-components" / "src" / "main" / "scala" / "be" / "doeraene" / "webcomponents" / "ui5" / "configkeys"
val configKeysFullPackageName = "be.doeraene.webcomponents.ui5.configkeys"
val generateIcons = taskKey[List[File]]("Generate the code files necessary to use the icons from sap")
generateIcons := {
CodeGeneration
.generateIconsFiles(configKeysFullPackageName, configKeyFolder)
.map(_.toString)
.map(file)
}
val checkGeneratedFilesUpToDate =
taskKey[Unit]("Check that the content of the generated files is correct, otherwise fail.")
val generateIllustratedMessages =
taskKey[List[File]]("Generate the code files necessary to use the illustrated messages from sap")
generateIllustratedMessages := {
CodeGeneration
.generateIllustratedMessagesFiles(configKeysFullPackageName, configKeyFolder)
.map(_.toString)
.map(file)
}
checkGeneratedFilesUpToDate := {
CodeGeneration.checkFilesAreUpToDate(configKeysFullPackageName, configKeyFolder) match {
case Left(value) =>
streams.value.log.error(value)
throw new IllegalStateException(value)
case Right(()) => ()
}
streams.value.log.info("All generated files are up to date.")
}