Skip to content

Commit

Permalink
Move scaladoc-only concerns to a file
Browse files Browse the repository at this point in the history
  • Loading branch information
exoego committed Jul 3, 2019
1 parent 14f0fe5 commit 5e5e942
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
16 changes: 2 additions & 14 deletions build.sbt
Expand Up @@ -47,7 +47,6 @@ val asmDep = "org.scala-lang.modules" % "scala-asm"
val jlineDep = "jline" % "jline" % versionProps("jline.version")
val testInterfaceDep = "org.scala-sbt" % "test-interface" % "1.0"
val diffUtilsDep = "com.googlecode.java-diff-utils" % "diffutils" % "1.3.0"
val jqueryDep = "org.webjars" % "jquery" % "3.4.1"

lazy val publishSettings : Seq[Setting[_]] = Seq(
credentials ++= {
Expand Down Expand Up @@ -499,19 +498,8 @@ lazy val scaladoc = configureAsSubproject(project)
name := "scala-compiler-doc",
description := "Scala Documentation Generator",
includeFilter in unmanagedResources in Compile := "*.html" | "*.css" | "*.gif" | "*.png" | "*.js" | "*.txt" | "*.svg" | "*.eot" | "*.woff" | "*.ttf",
libraryDependencies += jqueryDep,
resourceGenerators in Compile += 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)
val classpathes = (dependencyClasspath in Compile).value
val files: Seq[File] = classpathes.filter(isWebjar).flatMap { classpathEntry =>
val jarFile = classpathEntry.data
IO.unzip(jarFile, dest)
}
(files ** "*.min.js").get()
}.taskValue
libraryDependencies ++= ScaladocSettings.webjarResoources,
resourceGenerators in Compile += ScaladocSettings.extractResourcesFromWebjar
)
.dependsOn(compiler)

Expand Down
25 changes: 25 additions & 0 deletions project/ScaladocSettings.scala
@@ -0,0 +1,25 @@
package scala.build

import sbt._
import sbt.Keys.{ artifact, dependencyClasspath, moduleID, resourceManaged }

object ScaladocSettings {

val webjarResoources = Seq(
"org.webjars" % "jquery" % "3.4.1"
)

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)
val classpathes = (dependencyClasspath in Compile).value
val files: Seq[File] = classpathes.filter(isWebjar).flatMap { classpathEntry =>
val jarFile = classpathEntry.data
IO.unzip(jarFile, dest)
}
(files ** "*.min.js").get()
}

}

0 comments on commit 5e5e942

Please sign in to comment.