/
build.sbt
58 lines (52 loc) · 2.14 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
import scala.sys.process._
val scala2_12 = "2.12.18"
val scala2_13 = "2.13.12"
val libName = "sbt-accessibility-linter"
val npmTest = TaskKey[Unit]("npm-test")
lazy val root = Project(libName, file("."))
.enablePlugins(SbtPlugin)
.settings(
name := libName,
scalaVersion := scala2_12,
crossScalaVersions := Seq(scala2_12, scala2_13),
isPublicArtefact := true,
majorVersion := 0,
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "3.2.9" % "test",
"com.vladsch.flexmark" % "flexmark-all" % "0.35.10" % "test"
),
scriptedLaunchOpts := {
val homeDir = sys.props.get("jenkins.home")
.orElse(sys.props.get("user.home"))
.getOrElse("")
scriptedLaunchOpts.value ++
Seq(
"-Xmx1024M",
"-Dplugin.version=" + version.value,
s"-Dsbt.override.build.repos=${sys.props.getOrElse("sbt.override.build.repos", "false")}",
// s"-Dsbt.global.base=$sbtHome/.sbt",
// Global base is overwritten with <tmp scripted>/global and can not be reconfigured
// We have to explicitly set all the params that rely on base
s"-Dsbt.boot.directory=${file(homeDir) / ".sbt" / "boot"}",
s"-Dsbt.repository.config=${file(homeDir) / ".sbt" / "repositories"}"
)
},
scriptedBufferLog := false,
npmTest := {
val exitCode = ("npm install" #&& "npm test").!
if (exitCode != 0) {
throw new MessageOnlyException("npm install and test failed")
}
},
(Test / test) := (Test / test).dependsOn(npmTest).value,
Compile / resourceGenerators += Def.task {
val rootDirectory = baseDirectory.value
val destination: File = (Compile / resourceManaged).value / "js"
IO.copyDirectory(rootDirectory / "js" / "src", destination)
IO.copyFile(rootDirectory / "package.json", destination / "package.json")
IO.copyFile(rootDirectory / "package-lock.json", destination / "package-lock.json")
Path.allSubpaths(destination)
.collect { case (f, _) if !f.isDirectory => f }
.toSeq
}.taskValue
)