Last active
December 19, 2015 10:19
-
-
Save cchantep/5940062 to your computer and use it in GitHub Desktop.
Loading Maven/POM settings from SBT
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
// Use Maven groupId as SBT organization | |
organization <<= (baseDirectory in Compile) { base ⇒ | |
import scala.xml.XML | |
val pomFile = base / "pom.xml" | |
XML.loadFile(pomFile) \\ "project" \ "groupId" text | |
} | |
// Use Maven artifactId as SBT name | |
name <<= (baseDirectory in Compile) { base ⇒ | |
import scala.xml.XML | |
val pomFile = base / "pom.xml" | |
XML.loadFile(pomFile) \\ "project" \ "artifactId" text | |
} | |
// Use Maven version as SBT one | |
version <<= (baseDirectory in Compile) { base ⇒ | |
import scala.xml.XML | |
val pomFile = base / "pom.xml" | |
XML.loadFile(pomFile) \\ "project" \ "version" text | |
} | |
// Use Maven repositories as SBT resolvers, which is not managed by `externalPom()` | |
resolvers <<= (baseDirectory in Compile) { base ⇒ | |
import scala.xml.XML | |
val pomFile = base / "pom.xml" | |
val pom = XML.loadFile(pomFile) | |
val repositories = pom \\ "project" \ | |
"repositories" \ "repository" | |
repositories map { r ⇒ | |
(r \ "name").text at (r \ "url").text | |
} | |
} | |
// Loads SBT dependencies from Maven POM | |
externalPom() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment