Skip to content

Instantly share code, notes, and snippets.

@olafurpg
Last active May 24, 2019 19:47
Show Gist options
  • Save olafurpg/02cef3995f9ef702fa055b4cee90ac98 to your computer and use it in GitHub Desktop.
Save olafurpg/02cef3995f9ef702fa055b4cee90ac98 to your computer and use it in GitHub Desktop.
Script to download all library sources into a target directory
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
)
}
}
@olafurpg
Copy link
Author

olafurpg commented May 24, 2019

At the root of your sbt build run the following commands

wget -O project/DownloadSources.scala https://gist.githubusercontent.com/olafurpg/02cef3995f9ef702fa055b4cee90ac98/raw/d04cfe95650b234a830a3f53634ca58dab50fec7/DownloadSources.scala
sbt "all downloadSources"
cd target/sources
grep "???" # Enjoy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment