-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
167 lines (158 loc) · 5.38 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
import Libs._
import org.openqa.selenium.chrome.ChromeOptions
import org.scalajs.jsenv.selenium.SeleniumJSEnv
import sbt.io.Path.userHome
import sbt.librarymanagement.Patterns
import _root_.io.github.bonigarcia.wdm.WebDriverManager
import scala.collection.JavaConverters.asScalaBufferConverter
lazy val LocalMavenResolverForSbtPlugins = {
// remove scala and sbt versions from the path, as it does not work with jitpack
val pattern = "[organisation]/[module]/[revision]/[module]-[revision](-[classifier]).[ext]"
val name = "local-maven-for-sbt-plugins"
val location = userHome / ".m2" / "repository"
Resolver.file(name, location)(Patterns().withArtifactPatterns(Vector(pattern)))
}
inThisBuild(
Seq(
version := "0.1.0-SNAPSHOT",
organization := "com.github.mushtaq.sbt-snowpack",
organizationName := "ThoughtWorks",
resolvers += "jitpack" at "https://jitpack.io",
scalafmtOnCompile := true,
licenses := Seq(
("Apache-2.0", url("http://www.apache.org/licenses/LICENSE-2.0"))
)
)
)
lazy val `sbt-snowpack-root` = project
.in(file("."))
.aggregate(`sbt-snowpack`, `example`)
lazy val `sbt-snowpack` = project
.enablePlugins(SbtPlugin)
.settings(
scalaVersion := "2.12.13",
scriptedLaunchOpts += ("-Dplugin.version=" + version.value),
scriptedLaunchOpts ++= {
val list = java.lang.management.ManagementFactory.getRuntimeMXBean.getInputArguments.asScala.toList
list.filter(a => Seq("-Xmx", "-Xms", "-XX", "-Dsbt.log.noformat").exists(a.startsWith))
},
scriptedBufferLog := false,
publishMavenStyle := true,
resolvers += LocalMavenResolverForSbtPlugins,
publishM2Configuration := publishM2Configuration.value.withResolverName(LocalMavenResolverForSbtPlugins.name),
scalacOptions ++= Seq(
"-encoding",
"UTF-8",
"-feature",
"-unchecked",
"-deprecation",
"-Xlint:-unused,_",
"-Ywarn-dead-code",
"-Xfuture"
),
// below settings are duplicated in both build.sbt and plugins.sbt
// this is due to recursive source dependency in plugins.sbt via 'unmanagedSourceDirectories'
// recursion is *very* convenient as it allows a test example and plugin itself to exist in the same repo
libraryDependencies += "com.typesafe.play" %% "play-json" % "2.9.2",
libraryDependencies += "org.scala-js" %% "scalajs-env-selenium" % "1.1.1",
// note, 'sbt-scalajs' must come after 'scalajs-env-selenium'
// reference: https://github.com/scala-js/scala-js-env-selenium#usage
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.7.1")
)
lazy val `example` = project
.enablePlugins(ScalaJSPlugin, SnowpackPlugin)
.settings(
libraryDependencies ++= Seq(
scalatest.value % Test,
`scala-async`,
ScalablyTyped.R.rxjs
),
scalaVersion := "2.13.5",
scalacOptions ++= Seq(
"-encoding",
"UTF-8",
"-feature",
"-unchecked",
"-deprecation",
"-Wconf:any:warning-verbose",
"-Wdead-code",
"-Xlint:_,-missing-interpolator",
"-Xsource:3",
"-Xasync",
"-Xcheckinit"
// "-Xasync" does not work with Scala.js js yet
)
)
def seleniumConfig(port: Int, base: String): SeleniumJSEnv.Config = {
// WebDriverManager.chromedriver().setup()
val contentDirName = "selenium"
val webRoot = s"http://localhost:$port/$contentDirName/"
val contentDir = s"$base/$contentDirName"
SeleniumJSEnv
.Config()
.withMaterializeInServer(contentDir, webRoot)
}
lazy val `example-plain` = project
.enablePlugins(ScalaJSPlugin)
.settings(
scalaJSUseMainModuleInitializer := true,
scalaJSLinkerConfig ~= { _.withModuleKind(ModuleKind.ESModule).withSourceMap(false) },
Test / jsEnv := {
new SeleniumJSEnv(
new ChromeOptions().setHeadless(true),
seleniumConfig(9091, crossTarget.value.getAbsolutePath)
)
},
libraryDependencies ++= Seq(
scalatest.value % Test,
`scala-async`,
ScalablyTyped.R.rxjs
),
scalaVersion := "2.13.5",
scalacOptions ++= Seq(
"-encoding",
"UTF-8",
"-feature",
"-unchecked",
"-deprecation",
"-Wconf:any:warning-verbose",
"-Wdead-code",
"-Xlint:_,-missing-interpolator",
"-Xsource:3",
"-Xasync",
"-Xcheckinit"
// "-Xasync" does not work with Scala.js js yet
)
)
lazy val `vite-project` = project
.enablePlugins(ScalaJSPlugin)
.settings(
scalaJSUseMainModuleInitializer := true,
scalaJSLinkerConfig ~= { _.withModuleKind(ModuleKind.ESModule).withSourceMap(false) },
Test / jsEnv := {
new SeleniumJSEnv(
new ChromeOptions().setHeadless(true),
seleniumConfig(3000, baseDirectory.value.getAbsolutePath)
)
},
libraryDependencies ++= Seq(
scalatest.value % Test,
`scala-async`,
ScalablyTyped.R.rxjs
),
scalaVersion := "2.13.5",
scalacOptions ++= Seq(
"-encoding",
"UTF-8",
"-feature",
"-unchecked",
"-deprecation",
"-Wconf:any:warning-verbose",
"-Wdead-code",
"-Xlint:_,-missing-interpolator",
"-Xsource:3",
"-Xasync",
"-Xcheckinit"
// "-Xasync" does not work with Scala.js js yet
)
)