Piotr Gabryanczyk’s Blog

Java, Refactoring, AOP, Spring, DDD, TDD, etc.

  • Blogroll

    • I have joined Anti-IF Campaign

Posts Tagged ‘maven’

Converting Maven pom.xml to SBT

Posted by Piotr Gabryanczyk on November 14, 2010

Add this task to your project class.
Run reload, then pom2sbt.
Copy the output to the project file and enjoy!

lazy val pom2sbt = task {
    val deps = XML.load("pom.xml") \\ "dependencies"
    deps \"dependency" foreach( (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("[-\\.]", "_")

      print("val %s = \"%s\" %% \"%s\" %% \"%s\"".format(artifactValName, groupId, artifactId, version))
      scope match  {
        case "" => print("\n")
        case _ => print(" %% \"%s\"\n".format(scope))
      }
      None
    } )
    None
  }
Advertisements

Posted in Uncategorized | Tagged: , , , , | 1 Comment »