Skip to content

Instantly share code, notes, and snippets.

@johanprinsloo
Forked from retronym/mvn2sbt.scala
Created March 30, 2012 05:51
Show Gist options
  • Save johanprinsloo/2247012 to your computer and use it in GitHub Desktop.
Save johanprinsloo/2247012 to your computer and use it in GitHub Desktop.
mvn2sbt: quick hack to turn <dependencies> into SBT
#!/bin/sh
SCRIPT="$(cd "${0%/*}" 2>/dev/null; echo "$PWD"/"${0##*/}")"
DIR=`dirname "${SCRIPT}"}`
exec scala -savecompiled $0 $DIR $SCRIPT
::!#
import scala.xml._
object App {
def main(args: Array[String]): Unit = {
object scala {
val version = "SCALA_VERSION$"
}
val xml = XML.loadString(io.Source.stdin.getLines.mkString)
val data: Seq[(String, String, String)] = (xml \\ "dependency") map { d =>
val groupId = d \ "groupId" text
val artifactId = d \ "artifactId" text
val versionNum = d \ "version" text
(groupId, artifactId, versionNum)
}
val CrossBuildArtifact = """([\w-]+)_\$SCALA_VERSION\$""".r
def dep(a: String, g: String, v: String, cross: Boolean) = {
val sep = if (cross) "%%" else "%"
val ident = a.split("-").map(_.capitalize).mkString
"""val %s = "%s" %s "%s" %% "%s" """ format (ident, g, sep, a, v)
}
val m = data map {
case (g, CrossBuildArtifact(a), v) => dep(a, g, v, true)
case (g, a, v) => dep(a, g, v, false)
} mkString("\n")
println(m)
}
}
val Scalala_$SCALA_VERSION$ = "org.scalanlp" % "scalala_$SCALA_VERSION$" % "0.3.1"
val CommonsIo = "commons-io" % "commons-io" % "1.4"
val CommonsLang = "commons-lang" % "commons-lang" % "2.4"
val JodaTime = "joda-time" % "joda-time" % "1.6"
val JodaTimeHibernate = "joda-time" % "joda-time-hibernate" % "1.1"
val ScalaLibrary = "org.scala-lang" % "scala-library" % "$SCALA_VERSION$"
val ScalaCompiler = "org.scala-lang" % "scala-compiler" % "$SCALA_VERSION$"
val ScalazCore_$SCALA_VERSION$ = "com.googlecode.scalaz" % "scalaz-core_$SCALA_VERSION$" % "5.0-SNAPSHOT"
val Specs_$SCALA_VERSION$ = "org.scala-tools.testing" % "specs_$SCALA_VERSION$" % "1.6.5-SNAPSHOT"
val Junit = "junit" % "junit" % "4.7"
val TestInterface = "org.scala-tools.testing" % "test-interface" % "0.5"
val Scalatest = "org.scalatest" % "scalatest" % "1.0.1-for-scala-$SCALA_VERSION$-SNAPSHOT"
val Easymock = "org.easymock" % "easymock" % "2.5.1"
val Easymockclassextension = "org.easymock" % "easymockclassextension" % "2.4"
val Scalacheck_$SCALA_VERSION$ = "org.scala-tools.testing" % "scalacheck_$SCALA_VERSION$" % "1.7"
val Jmock = "org.jmock" % "jmock" % "2.5.1"
val JmockLegacy = "org.jmock" % "jmock-legacy" % "2.5.1"
val MockitoAll = "org.mockito" % "mockito-all" % "1.8.4"
val Cglib = "cglib" % "cglib" % "2.1_3"
val Objenesis = "org.objenesis" % "objenesis" % "1.0"
val DatecalcJoda = "net.objectlab.kit.datecalc" % "datecalc-joda" % "1.1.0"
val DatecalcCommon = "net.objectlab.kit.datecalc" % "datecalc-common" % "1.1.0"
val CommonsMath = "org.apache.commons" % "commons-math" % "2.0"
cat pom.xml | ./gensbtdeps.scala > deps.sbt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment