Last active
May 24, 2019 19:47
-
-
Save olafurpg/02cef3995f9ef702fa055b4cee90ac98 to your computer and use it in GitHub Desktop.
Script to download all library sources into a target directory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sbt._, Keys._ | |
object DownloadSources extends AutoPlugin { | |
override def trigger = allRequirements | |
override def requires = sbt.plugins.JvmPlugin | |
override def projectSettings = | |
List(Compile, Test).flatMap { config => | |
inConfig(config)( | |
TaskKey[Seq[File]]("downloadSources") := Def.task[Seq[File]] { | |
val out = baseDirectory.in(ThisBuild).value / "target" / "sources" | |
val sourceJars = for { | |
configurationReport <- updateClassifiers.value.configurations | |
moduleReport <- configurationReport.modules | |
(artifact, file) <- moduleReport.artifacts | |
if artifact.classifier.exists(_ == "sources") | |
_ = IO.unzip(file, out) | |
} yield file | |
sourceJars.distinct | |
}.value | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
At the root of your sbt build run the following commands