|
1 |
| -import _root_.scalafix.sbt.BuildInfo.scalafixVersion |
2 |
| -import scalatex.ScalatexReadme |
3 |
| - |
4 |
| -ThisBuild / shellPrompt := ((s: State) => Project.extract(s).currentRef.project + "> ") |
5 |
| - |
6 |
| -lazy val scalafixRules = project |
7 |
| - .in(file("scalafix")) |
8 |
| - .settings( |
9 |
| - libraryDependencies += ("ch.epfl.scala" %% "scalafix-core" % scalafixVersion).cross(CrossVersion.for3Use2_13), |
10 |
| - ) |
11 |
| - |
12 |
| -def sourceMapsToGithub: Project => Project = |
13 |
| - p => p.settings( |
14 |
| - scalacOptions ++= { |
15 |
| - val isDotty = scalaVersion.value startsWith "3" |
16 |
| - val ver = version.value |
17 |
| - if (isSnapshot.value) |
18 |
| - Nil |
19 |
| - else { |
20 |
| - val a = p.base.toURI.toString.replaceFirst("[^/]+/?$", "") |
21 |
| - val g = s"https://raw.githubusercontent.com/scala-js/scala-js-dom" |
22 |
| - val flag = if (isDotty) "-scalajs-mapSourceURI" else "-P:scalajs:mapSourceURI" |
23 |
| - s"$flag:$a->$g/v$ver/" :: Nil |
24 |
| - } |
25 |
| - } |
26 |
| - ) |
27 |
| - |
28 |
| -lazy val root = project |
29 |
| - .in(file(".")) |
30 |
| - .enablePlugins(ScalaJSPlugin) |
31 |
| - .enablePlugins(ScalafixPlugin) |
32 |
| - .dependsOn(scalafixRules % ScalafixConfig) |
33 |
| - .configure(sourceMapsToGithub) |
34 |
| - |
35 |
| -name := "Scala.js DOM" |
36 |
| - |
37 |
| -ThisBuild / crossScalaVersions := Seq("2.11.12", "2.12.12", "2.13.4", "3.0.1") |
38 |
| -ThisBuild / scalaVersion := crossScalaVersions.value.find(_.startsWith("2.13.")).get |
39 |
| - |
40 |
| -val inCI = Option(System.getenv("CI")).exists(_.contains("1")) |
41 |
| - |
42 |
| -val commonSettings = Seq( |
43 |
| - organization := "org.scala-js", |
44 |
| - scalacOptions ++= Seq( |
45 |
| - "-deprecation", |
46 |
| - "-feature", |
47 |
| - ), |
48 |
| - scalacOptions ++= (if (!inCI) Seq.empty else Seq( |
49 |
| - "-Xfatal-warnings", |
50 |
| - )), |
51 |
| - scalacOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match { |
52 |
| - case Some((2, 11)) => "-Ywarn-unused-import" :: Nil |
53 |
| - case Some((2, 12)) => "-Ywarn-unused:imports,patvars,locals,implicits" :: Nil |
54 |
| - case Some((2, 13)) => "-Wunused:imports,patvars,locals,implicits" :: Nil |
55 |
| - case _ => Nil |
56 |
| - }), |
57 |
| -) |
58 |
| - |
59 |
| -val noPublishSettings = Seq( |
60 |
| - publish / skip := true |
61 |
| -) |
62 |
| - |
63 |
| -normalizedName := "scalajs-dom" |
64 |
| - |
65 |
| -commonSettings |
66 |
| - |
67 |
| -homepage := Some(url("http://scala-js.org/")) |
68 |
| - |
69 |
| -licenses += ("MIT", url("http://opensource.org/licenses/mit-license.php")) |
70 |
| - |
71 |
| -def hasNewCollections(version: String): Boolean = { |
72 |
| - !version.startsWith("2.11.") && |
73 |
| - !version.startsWith("2.12.") |
74 |
| -} |
75 |
| - |
76 |
| -/** Returns the appropriate subdirectory of `sourceDir` depending on whether |
77 |
| - * the `scalaV` uses the new collections (introduced in 2.13) or not. |
78 |
| - */ |
79 |
| -def collectionsEraDependentDirectory(scalaV: String, sourceDir: File): File = |
80 |
| - if (hasNewCollections(scalaV)) sourceDir / "scala-new-collections" |
81 |
| - else sourceDir / "scala-old-collections" |
82 |
| - |
83 |
| -inConfig(Compile)(Def.settings( |
84 |
| - unmanagedSourceDirectories += |
85 |
| - collectionsEraDependentDirectory(scalaVersion.value, sourceDirectory.value) |
86 |
| -)) |
87 |
| - |
88 |
| -versionScheme := Some("early-semver") |
89 |
| - |
90 |
| -pomExtra := ( |
91 |
| - <developers> |
92 |
| - <developer> |
93 |
| - <id>japgolly</id> |
94 |
| - <name>David Barri</name> |
95 |
| - <url>https://github.com/japgolly</url> |
96 |
| - </developer> |
97 |
| - <developer> |
98 |
| - <id>lihaoyi</id> |
99 |
| - <name>Li Haoyi</name> |
100 |
| - <url>https://github.com/lihaoyi/</url> |
101 |
| - </developer> |
102 |
| - <developer> |
103 |
| - <id>armanbilge</id> |
104 |
| - <name>Arman Bilge</name> |
105 |
| - <url>https://github.com/armanbilge</url> |
106 |
| - </developer> |
107 |
| - <developer> |
108 |
| - <id>sjrd</id> |
109 |
| - <name>Sébastien Doeraene</name> |
110 |
| - <url>https://github.com/sjrd/</url> |
111 |
| - </developer> |
112 |
| - <developer> |
113 |
| - <id>gzm0</id> |
114 |
| - <name>Tobias Schlatter</name> |
115 |
| - <url>https://github.com/gzm0/</url> |
116 |
| - </developer> |
117 |
| - </developers> |
118 |
| -) |
119 |
| - |
120 |
| -pomIncludeRepository := { _ => false } |
121 |
| - |
122 |
| -lazy val readme = ScalatexReadme( |
123 |
| - projectId = "readme", |
124 |
| - wd = file(""), |
125 |
| - url = "https://github.com/scala-js/scala-js-dom/tree/master", |
126 |
| - source = "Index", |
127 |
| - autoResources = Seq("example-opt.js") |
128 |
| -).settings( |
129 |
| - scalaVersion := "2.12.10", |
130 |
| - scalacOptions ++= Seq("-deprecation", "-feature", "-Xfatal-warnings"), |
131 |
| - (Compile / resources) += (example / Compile / fullOptJS).value.data |
132 |
| -).settings(noPublishSettings: _*) |
133 |
| - |
134 |
| -lazy val example = project. |
135 |
| - enablePlugins(ScalaJSPlugin). |
136 |
| - settings(commonSettings: _*). |
137 |
| - settings(noPublishSettings: _*). |
138 |
| - dependsOn(root) |
139 |
| - |
140 |
| -addCommandAlias("prePR", "+prePR_nonCross") |
141 |
| - |
142 |
| -val prePR_nonCross = taskKey[Unit]("Performs all necessary work required before submitting a PR, for a single version of Scala.") |
143 |
| - |
144 |
| -ThisBuild / prePR_nonCross := Def.sequential( |
145 |
| - root / clean, |
146 |
| - root / Compile / scalafmt, |
147 |
| - Def.taskDyn { |
148 |
| - if (scalaVersion.value.startsWith("2.")) |
149 |
| - (root / Compile / scalafix).toTask("") |
150 |
| - else |
151 |
| - Def.task[Unit]((root / Compile / compile).value) |
152 |
| - }, |
153 |
| - example / Compile / compile, |
154 |
| -).value |
| 1 | +ThisBuild / homepage := Some(url("https://scala-js.org")) |
| 2 | +ThisBuild / licenses += ("MIT", url("https://opensource.org/licenses/mit-license.php")) |
| 3 | +ThisBuild / organization := "org.scala-js" |
| 4 | +ThisBuild / shellPrompt := ((s: State) => Project.extract(s).currentRef.project + "> ") |
| 5 | +ThisBuild / versionScheme := Some("early-semver") |
| 6 | + |
| 7 | +val root = Build.root |
| 8 | +val scalafixRules = Build.scalafixRules |
| 9 | +val dom = Build.dom |
| 10 | +val testsShared = Build.testsShared |
| 11 | +val testsWebworker = Build.testsWebworker |
| 12 | +val testsChrome = Build.testsChrome |
| 13 | +val testsFirefox = Build.testsFirefox |
| 14 | +val testsNodeJsdom = Build.testsNodeJsdom |
| 15 | +val example = Build.example |
| 16 | +val readme = Build.readme |
| 17 | + |
| 18 | +// TODO: Remove after dom project get it's own directory |
| 19 | +Global / onLoad ~= (_.andThen("project root" :: _)) |
0 commit comments