Skip to content
Snippets Groups Projects
Commit 270578f2 authored by Nicolas Voirol's avatar Nicolas Voirol
Browse files

Added svn+credentials resolver scheme to sbt build

parent 382f1a2f
No related branches found
No related tags found
No related merge requests found
......@@ -55,12 +55,15 @@ lazy val ItTest = config("it") extend(Test)
testOptions in ItTest := Seq(Tests.Argument("-oDF"))
def ghProject(repo: String, version: String) = RootProject(uri(s"${repo}#${version}"))
def ghProject(repo: String, version: String) = RootProject(uri(s"git://$repo#$version"))
lazy val bonsai = ghProject("git://github.com/colder/bonsai.git", "10eaaee4ea0ff6567f4f866922cb871bae2da0ac")
lazy val scalaSmtlib = ghProject("git://github.com/regb/scala-smtlib.git", "850580ae86e299a1baa0eaef9e24eed905fefe58")
def svnProject(repo: String, version: String, user: String, pass: String) =
RootProject(uri(s"svn+credentials://$repo#username=$user&password=$pass&$version"))
lazy val princess = ghProject("svn://hal4.it.uu.se/princess/interpolation/trunk", "2703")
lazy val bonsai = ghProject("github.com/colder/bonsai.git", "10eaaee4ea0ff6567f4f866922cb871bae2da0ac")
lazy val scalaSmtlib = ghProject("github.com/regb/scala-smtlib.git", "850580ae86e299a1baa0eaef9e24eed905fefe58")
lazy val princess = svnProject("hal4.it.uu.se/princess/interpolation/trunk", "2703", "anonymous", "anonymous")
// XXX @nv: complex hack to make sure we don't have a name clash between
// princess' smtlib parser and the scala-smtlib one.
......
import sbt._
import Keys._
import RichURI._
object InoxBuild extends Build {
override def buildLoaders = BuildLoader.resolve(svnResolver) :: Nil
// Define the custom resolver which handles the 'svn' scheme with a username/password pair.
def svnResolver(info: BuildLoader.ResolveInfo): Option[() => File] =
if (info.uri.getScheme != "svn+credentials") None else {
val uri = info.uri.withoutMarkerScheme
val localCopy = Resolvers.uniqueSubdirectoryFor(uri, in = info.staging)
val from = uri.copy(scheme = "svn").withoutFragment.toASCIIString
val to = localCopy.getAbsolutePath
sealed abstract class SVNInfo
case class Username(user: String) extends SVNInfo
case class Password(pass: String) extends SVNInfo
case class Tag(tag: String) extends SVNInfo
val fragment = uri.getFragment
val splits = fragment.split("&").toSeq
val infos = splits.map(s => s.split("=").toSeq match {
case Seq("username", user) => Username(user)
case Seq("password", pass) => Password(pass)
case Seq(tag) => Tag(tag)
case _ => sys.error("Unexpected fragment: " + fragment)
})
val username = infos.collect { case Username(user) => user } match {
case Seq(user) => user
case _ => sys.error("Invalid username specification for svn+credentials scheme.")
}
val password = infos.collect { case Password(pass) => pass } match {
case Seq(pass) => pass
case _ => sys.error("Invalid password specification for svn+credentials scheme.")
}
infos.collect { case Tag(tag) => tag } match {
case Seq(tag) => Some(() => Resolvers.creates(localCopy) {
Resolvers.run("svn", "checkout", "-q", "-r", tag, "--username", username, "--password", password, from, to)
})
case Seq() => Some(() => Resolvers.creates(localCopy) {
Resolvers.run("svn", "checkout", "-q", "--username", username, "--password", password, from, to)
})
case _ => sys.error("Invalid tag specification for svn+credentials scheme.")
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment