-
-
Save OleTraveler/1042926 to your computer and use it in GitHub Desktop.
mvn2sbt: updated to convert to 0.10.0 build.sbt file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val xml = <dependencies> | |
<dependency> | |
<groupId>javax.persistence</groupId> | |
<artifactId>persistence-api</artifactId> | |
<version>1.0</version> | |
<scope>provided</scope> | |
</dependency> | |
<dependency> | |
<groupId>net.sf.oval</groupId> | |
<artifactId>oval</artifactId> | |
<version>1.70</version> | |
</dependency> | |
</dependencies> | |
val data: Seq[(String, String, String, Option[String])] = (xml \ "dependency") map { d => | |
val groupId = d \ "groupId" text | |
val artifactId = d \ "artifactId" text | |
val versionNum = d \ "version" text | |
val scope = d \ "scope" text | |
(groupId, artifactId, versionNum, if (scope.size > 0) Some(scope) else None) | |
} | |
val CrossBuildArtifact = """([\w-]+)_\$SCALA_VERSION\$""".r | |
def dep(a: String, g: String, v: String, s: Option[String], cross: Boolean) = { | |
val sep = if (cross) "%%" else "%" | |
val ident = a.split("-").map(_.capitalize).mkString | |
val base = """ "%s" %s "%s" %% "%s" """ format (g, sep, a, v) | |
base + s.map(" % \"" + _ + "\"").getOrElse("") | |
} | |
val m = data map { | |
case (g, CrossBuildArtifact(a), v, s) => dep(a, g, v, s, true) | |
case (g, a, v, s) => dep(a, g, v, s, false) | |
} mkString(",\n") | |
println(m) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"javax.persistence" % "persistence-api" % "1.0" % "provided", | |
"net.sf.oval" % "oval" % "1.70" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment