forked from scalacenter/scalajs-bundler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
163 lines (149 loc) · 5.75 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
import sbtunidoc.Plugin.ScalaUnidoc
import sbtunidoc.Plugin.UnidocKeys.unidoc
val runScripted = taskKey[Unit]("Run supported sbt scripted tests")
val `sbt-scalajs-bundler` =
project.in(file("sbt-scalajs-bundler"))
.settings(commonSettings)
.settings(
sbtPlugin := true,
name := "sbt-scalajs-bundler",
description := "Module bundler for Scala.js projects",
libraryDependencies += "com.typesafe.play" %% "play-json" % "2.6.7",
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.22")
)
val `sbt-web-scalajs-bundler` =
project.in(file("sbt-web-scalajs-bundler"))
.settings(commonSettings)
.settings(
sbtPlugin := true,
scriptedDependencies := {
val () = scriptedDependencies.value
val () = publishLocal.value
val () = (publishLocal in `sbt-scalajs-bundler`).value
},
name := "sbt-web-scalajs-bundler",
description := "Module bundler for Scala.js projects (integration with sbt-web-scalajs)",
addSbtPlugin("com.vmunier" % "sbt-web-scalajs" % "1.0.6")
)
.dependsOn(`sbt-scalajs-bundler`)
// Dummy project that exists just for the purpose of aggregating the two sbt
// plugins. I can not do that in the `doc` project below because the
// scalaVersion is not compatible.
val apiDoc =
project.in(file("api-doc"))
.settings(noPublishSettings ++ unidocSettings: _*)
.settings(
scalacOptions in (ScalaUnidoc, unidoc) ++= Seq(
"-groups",
"-doc-source-url", s"https://github.com/scalacenter/scalajs-bundler/blob/v${version.value}€{FILE_PATH}.scala",
"-sourcepath", (baseDirectory in ThisBuild).value.absolutePath
)
)
.aggregate(`sbt-scalajs-bundler`, `sbt-web-scalajs-bundler`)
val ornateTarget = Def.setting(target.value / "ornate")
val manual =
project.in(file("manual"))
.enablePlugins(OrnatePlugin)
.settings(noPublishSettings ++ ghpages.settings: _*)
.settings(
scalaVersion := "2.11.8",
git.remoteRepo := "[email protected]:scalacenter/scalajs-bundler.git",
ornateSourceDir := Some(sourceDirectory.value / "ornate"),
ornateTargetDir := Some(ornateTarget.value),
ornateSettings := Map("version" -> version.value),
siteSubdirName in ornate := "",
addMappingsToSiteDir(mappings in ornate, siteSubdirName in ornate),
mappings in ornate := {
val _ = ornate.value
val output = ornateTarget.value
output ** AllPassFilter --- output pair relativeTo(output)
},
siteSubdirName in packageDoc := "api/latest",
addMappingsToSiteDir(mappings in ScalaUnidoc in packageDoc in apiDoc, siteSubdirName in packageDoc)
)
val `scalajs-bundler` =
project.in(file("."))
.settings(noPublishSettings: _*)
.aggregate(`sbt-scalajs-bundler`, `sbt-web-scalajs-bundler`)
inScope(ThisScope.copy(project = Global))(List(
pgpPublicRing := file("./travis/local.pubring.asc"),
pgpSecretRing := file("./travis/local.secring.asc"),
pgpPassphrase := sys.env.get("PGP_PASS").map(_.toArray),
credentials ++= (
for {
username <- sys.env.get("SONATYPE_USER")
password <- sys.env.get("SONATYPE_PASSWORD")
} yield Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", username, password)
).toList,
scalacOptions ++= Seq(
"-feature",
"-deprecation",
"-encoding", "UTF-8",
"-unchecked",
"-Xlint",
"-Yno-adapted-args",
"-Ywarn-dead-code",
"-Ywarn-numeric-widen",
"-Ywarn-value-discard",
"-Xfuture"
),
scmInfo := Some(
ScmInfo(
url("https://github.com/scalacenter/scalajs-bundler"),
"scm:[email protected]:scalacenter/scalajs-bundler.git"
)
),
organization := "ch.epfl.scala",
homepage := Some(url(s"https://github.com/scalacenter/scalajs-bundler")),
licenses := Seq("MIT License" -> url("http://opensource.org/licenses/mit-license.php")),
developers := List(Developer("julienrf", "Julien Richard-Foy", "[email protected]", url("http://julien.richard-foy.fr")))
))
lazy val commonSettings = ScriptedPlugin.scriptedSettings ++ List(
runScripted := runScriptedTask.value,
scriptedLaunchOpts += "-Dplugin.version=" + version.value,
scriptedBufferLog := false,
crossSbtVersions := List("0.13.16", "1.0.2"),
scalaVersion := {
(sbtBinaryVersion in pluginCrossBuild).value match {
case "0.13" => "2.10.6"
case _ => "2.12.3"
}
},
// fixed in https://github.com/sbt/sbt/pull/3397 (for sbt 0.13.17)
sbtBinaryVersion in update := (sbtBinaryVersion in pluginCrossBuild).value
)
lazy val noPublishSettings =
Seq(
publishArtifact := false,
publish := (),
publishLocal := ()
)
def runScriptedTask = Def.taskDyn {
val sbtBinVersion = (sbtBinaryVersion in pluginCrossBuild).value
val base = sbtTestDirectory.value
def isCompatible(directory: File): Boolean = {
val buildProps = new java.util.Properties()
IO.load(buildProps, directory / "project" / "build.properties")
Option(buildProps.getProperty("sbt.version"))
.map { version =>
val requiredBinVersion = CrossVersion.binarySbtVersion(version)
val compatible = requiredBinVersion == sbtBinVersion
if (!compatible) {
val testName = directory.relativeTo(base).getOrElse(directory)
streams.value.log.warn(s"Skipping $testName since it requires sbt $requiredBinVersion")
}
compatible
}
.getOrElse(true)
}
val testDirectoryFinder = base * AllPassFilter * AllPassFilter filter { _.isDirectory }
val tests = for {
test <- testDirectoryFinder.get
if isCompatible(test)
path <- Path.relativeTo(base)(test)
} yield path.replace('\\', '/')
if (tests.nonEmpty)
Def.task(scripted.toTask(tests.mkString(" ", " ", "")).value)
else
Def.task(streams.value.log.warn("No tests can be run for this sbt version"))
}