-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.sbt
140 lines (125 loc) · 4.55 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
import org.openqa.selenium.WebDriver
import org.openqa.selenium.chrome.{ChromeDriver, ChromeOptions}
import org.openqa.selenium.firefox.{FirefoxOptions, FirefoxProfile}
import org.openqa.selenium.remote.server.{DriverFactory, DriverProvider}
import org.scalajs.jsenv.jsdomnodejs.JSDOMNodeJSEnv
import org.scalajs.jsenv.nodejs.NodeJSEnv
import org.scalajs.jsenv.selenium.SeleniumJSEnv
import java.util.concurrent.TimeUnit
import build.JSEnvKind
lazy val jsEnvKind =
settingKey[JSEnvKind]("Use Node.js or a headless browser for running Scala.js tests")
inThisBuild(Def.settings(
crossScalaVersions := Seq("2.12.15", "2.11.12", "2.13.8"),
scalaVersion := crossScalaVersions.value.head,
version := "1.0.1-SNAPSHOT",
organization := "org.scala-js",
scalacOptions ++= Seq(
"-encoding", "utf-8",
"-deprecation",
"-feature",
"-Xfatal-warnings",
),
// Licensing
homepage := Some(url("https://github.com/scala-js/scala-js-fake-insecure-java-securerandom")),
startYear := Some(2022),
licenses += (("Apache-2.0", url("https://www.apache.org/licenses/LICENSE-2.0"))),
scmInfo := Some(ScmInfo(
url("https://github.com/scala-js/scala-js-fake-insecure-java-securerandom"),
"scm:git:[email protected]:scala-js/scala-js-fake-insecure-java-securerandom.git",
Some("scm:git:[email protected]:scala-js/scala-js-fake-insecure-java-securerandom.git"))),
// Publishing
publishMavenStyle := true,
publishTo := {
val nexus = "https://oss.sonatype.org/"
if (version.value.endsWith("-SNAPSHOT"))
Some("snapshots" at nexus + "content/repositories/snapshots")
else
Some("releases" at nexus + "service/local/staging/deploy/maven2")
},
pomExtra := (
<developers>
<developer>
<id>sjrd</id>
<name>Sébastien Doeraene</name>
<url>https://github.com/sjrd/</url>
</developer>
<developer>
<id>gzm0</id>
<name>Tobias Schlatter</name>
<url>https://github.com/gzm0/</url>
</developer>
</developers>
),
pomIncludeRepository := { _ => false },
// Environments
jsEnvKind := JSEnvKind.NodeJS,
Test / jsEnv := {
import JSEnvKind._
jsEnvKind.value match {
case NodeJS =>
new NodeJSEnv()
case JSDOMNodeJS =>
new JSDOMNodeJSEnv()
case Firefox =>
val profile = new FirefoxProfile()
profile.setPreference("privacy.file_unique_origin", false)
val options = new FirefoxOptions()
options.setProfile(profile)
options.setHeadless(true)
new SeleniumJSEnv(options)
case Chrome =>
val options = new ChromeOptions()
options.setHeadless(true)
options.addArguments("--allow-file-access-from-files")
val factory = new DriverFactory {
val defaultFactory = SeleniumJSEnv.Config().driverFactory
def newInstance(capabilities: org.openqa.selenium.Capabilities): WebDriver = {
val driver = defaultFactory.newInstance(capabilities).asInstanceOf[ChromeDriver]
driver.manage().timeouts().pageLoadTimeout(1, TimeUnit.HOURS)
driver.manage().timeouts().setScriptTimeout(1, TimeUnit.HOURS)
driver
}
def registerDriverProvider(provider: DriverProvider): Unit =
defaultFactory.registerDriverProvider(provider)
}
new SeleniumJSEnv(options, SeleniumJSEnv.Config().withDriverFactory(factory))
}
},
))
val commonSettings = Def.settings(
// sbt-header configuration
headerLicense := Some(HeaderLicense.Custom(
s"""scalajs-fake-insecure-java-securerandom (${homepage.value.get})
|
|Copyright EPFL.
|
|Licensed under Apache License 2.0
|(https://www.apache.org/licenses/LICENSE-2.0).
|
|See the NOTICE file distributed with this work for
|additional information regarding copyright ownership.
|""".stripMargin
)),
)
lazy val root: Project = project.in(file("."))
.enablePlugins(ScalaJSPlugin)
.settings(commonSettings: _*)
.settings(
name := "scalajs-fake-insecure-java-securerandom",
Compile / packageBin / mappings ~= {
_.filter(!_._2.endsWith(".class"))
},
exportJars := true,
)
lazy val testSuite = crossProject(JSPlatform, JVMPlatform)
.in(file("test-suite"))
.jsConfigure(_.enablePlugins(ScalaJSJUnitPlugin))
.settings(commonSettings: _*)
.settings(
testOptions += Tests.Argument(TestFramework("com.novocode.junit.JUnitFramework"), "-v", "-a"),
)
.jsConfigure(_.dependsOn(root))
.jvmSettings(
libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % "test",
)