Wednesday, February 1, 2012

Small script to update & compile a list of svn project

Scala script skeleton to update a set of subversion projects.
#!/bin/sh
exec scala -deprecation -savecompiled "$0" "$@"
!#

// ======================================================================
import sys.process.Process
import sys.process.ProcessBuilder._

case class CurDir(cwd:java.io.File)
implicit def stringToCurDir(d:String) = CurDir(new java.io.File(d))
implicit def stringToProcess(cmd: String)(implicit curDir:CurDir) = Process(cmd, curDir.cwd)
implicit def stringSeqToProcess(cmd:Seq[String])(implicit curDir:CurDir) = Process(cmd, curDir.cwd)

implicit var cwd:CurDir=scala.util.Properties.userDir
def cd(dir:String=util.Properties.userDir) = cwd=dir
// ======================================================================

val updateList=List("project1", "project2", "project3")

for(dir<- updateList) {
  println("----------------------------------------")
  println("Processing %s".format(dir))

  cd(dir)

  "svn update" !

  "sbt eclipse compile" !
}

No comments:

Post a Comment