diff --git a/build.sbt b/build.sbt index 977109d77ea6..4567114640fe 100644 --- a/build.sbt +++ b/build.sbt @@ -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 ++= { @@ -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) diff --git a/project/ScaladocSettings.scala b/project/ScaladocSettings.scala new file mode 100644 index 000000000000..4535e01f9fe6 --- /dev/null +++ b/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() + } + +}