Skip to content

Instantly share code, notes, and snippets.

@dwijnand
Last active December 5, 2016 01:44
Show Gist options
  • Save dwijnand/06884f7dc5b43fe9b3b7 to your computer and use it in GitHub Desktop.
Save dwijnand/06884f7dc5b43fe9b3b7 to your computer and use it in GitHub Desktop.
Semi-port of "mvn dependency:list -Dsort=true -DoutputFile=deps.mvn.txt" to sbt
val dependencyList = taskKey[File]("")
val dependencyListDef = Def.task {
val f = baseDirectory.value / "deps.sbt.txt"
streams.value.log.info(s"Writing to $f")
IO.write(f, "\n")
IO.append(f, "The following files have been resolved:\n")
val cp = (managedClasspath in Test).value
val lines = cp map { att =>
val md = att.metadata
val m = md.get(Keys.moduleID.key).get
val a = md.get(Keys.artifact.key).get
s" ${m.organization}:${m.name}:${a.extension}:${m.revision}"
}
lines.sorted.foreach(l => IO.append(f, s"$l\n"))
IO.append(f, "\n")
f
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment