2019-07-01 18:41:41 +08:00
|
|
|
package scala.build
|
|
|
|
|
|
|
|
import sbt._
|
2021-09-03 03:30:49 +08:00
|
|
|
import sbt.Keys.{ artifact, externalDependencyClasspath, moduleID, resourceManaged }
|
2019-07-01 18:41:41 +08:00
|
|
|
|
|
|
|
object ScaladocSettings {
|
|
|
|
|
2020-05-06 09:22:32 +08:00
|
|
|
// when this changes, the integrity check in HtmlFactory.scala also needs updating
|
|
|
|
val webjarResources = Seq(
|
2023-09-13 11:04:13 +08:00
|
|
|
"org.webjars" % "jquery" % "3.7.1"
|
2019-07-01 18:41:41 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
def extractResourcesFromWebjar = Def.task {
|
|
|
|
def isWebjar(s: Attributed[File]): Boolean =
|
|
|
|
s.get(artifact.key).isDefined && s.get(moduleID.key).exists(_.organization == "org.webjars")
|
|
|
|
val dest = (resourceManaged.value / "webjars").getAbsoluteFile
|
|
|
|
IO.createDirectory(dest)
|
2021-09-03 03:30:49 +08:00
|
|
|
// externalDependencyClasspath (not dependencyClasspath) to avoid compiling
|
|
|
|
// upstream projects (library, reflect, compiler) on bsp `buildTarget/resources`
|
2022-01-19 13:09:17 +08:00
|
|
|
val classpaths = (Compile / externalDependencyClasspath).value
|
2021-12-24 01:04:35 +08:00
|
|
|
val files: Seq[File] = classpaths.filter(isWebjar).flatMap { classpathEntry =>
|
2019-07-01 18:41:41 +08:00
|
|
|
val jarFile = classpathEntry.data
|
|
|
|
IO.unzip(jarFile, dest)
|
|
|
|
}
|
|
|
|
(files ** "*.min.js").get()
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|