Skip to content

Instantly share code, notes, and snippets.

@motemen
Last active January 6, 2016 11:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save motemen/520af718837515a4acb4 to your computer and use it in GitHub Desktop.
Save motemen/520af718837515a4acb4 to your computer and use it in GitHub Desktop.
watchSources ~= {
_.filterNot {
f =>
f.isDirectory ||
"""^\..*\.sw.$""".r.findFirstIn(f.getName).isDefined
}
}
lazy val ghqGetDepndencies = TaskKey[Unit]("ghq-get-dependencies")
ghqGetDepndencies <<= (ivyModule, sLog) map {
(ivy, logger) =>
new IvyCache(None).withDefaultCache(None, logger) {
cache =>
ivy.moduleDescriptor(logger).getDependencies.map(_.getDependencyRevisionId).foreach {
modRevId =>
import scala.xml.parsing.ConstructingParser
val path = cache.getIvyFileInCache(modRevId).getPath
val doc = ConstructingParser.fromSource(io.Source.fromFile(s"$path.original"), preserveWS = false).document()
val scmConnectionNode = (doc \ "scm" \ "connection")
if (scmConnectionNode.nonEmpty) {
val scmConnection = scmConnectionNode.text
val pat = "^scm:(?:git|hg|svn):(.+)$".r
scmConnection match {
case pat(url) =>
logger.info(s"$modRevId :: $url")
Process(Seq("ghq", "get", url)) !
case _ =>
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment