Skip to content

Instantly share code, notes, and snippets.

@nwtgck
Created January 19, 2018 19:55
Show Gist options
  • Save nwtgck/ccc0d481aa6fc9cd1eac50a723bd0e5e to your computer and use it in GitHub Desktop.
Save nwtgck/ccc0d481aa6fc9cd1eac50a723bd0e5e to your computer and use it in GitHub Desktop.
// How to run
// cd <root which has pom.xml>
// scala PomToSbt.scala
// Then, you have output
object PomToSbt extends App{
// (from: https://stackoverflow.com/a/15430347/2885946)
import scala.xml._
val dependencies = ((XML.load("pom.xml") \\ "dependencies") \ "dependency").map((dependency: Node) => {
val groupId = (dependency \ "groupId").text
val artifactId = (dependency \ "artifactId").text
val version = (dependency \ "version").text
val scope = (dependency \ "scope").text
val classifier = (dependency \ "classifier").text
val artifactValName: String = artifactId.replaceAll("[-\\.]", "_")
s"${groupId} % ${artifactId} % ${version}"
})
println(dependencies.mkString(",\n"))
}
// How to run
// cd <root which has pom.xml>
// scala PomToSbt.scala
// Then, you have output
object PomToSbt extends App{
// (from: https://stackoverflow.com/a/15430347/2885946)
import scala.xml._
val dependencies = ((XML.load("pom.xml") \\ "dependencies") \ "dependency").map((dependency: Node) => {
val groupId = (dependency \ "groupId").text
val artifactId = (dependency \ "artifactId").text
val version = (dependency \ "version").text
val scope = (dependency \ "scope").text
val classifier = (dependency \ "classifier").text
val artifactValName: String = artifactId.replaceAll("[-\\.]", "_")
s"${groupId} % ${artifactId} % ${version}"
})
println(dependencies.mkString(",\n"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment