Permalink
Browse files

Now supports classifiers

  • Loading branch information...
1 parent e6c0ab4 commit edc094961217ba1f4fd0c5160dc50ac70aeb51bf @tackley committed Aug 14, 2011
@@ -4,7 +4,7 @@ import xml._
import collection.immutable.Map
import java.io.File
-case class Dependency(groupId: String, artifactId: String, version: String, scope: Option[String] = None) {
+case class Dependency(groupId: String, artifactId: String, version: String, scope: Option[String] = None, classifier: Option[String] = None) {
def substituteProps(props: Map[String, String]) = {
val Property = """^\$\{(.*)\}$""".r
@@ -16,9 +16,10 @@ case class Dependency(groupId: String, artifactId: String, version: String, scop
this.copy(version = subst(version))
}
- def asSbt = quote(groupId) + " % " + quote(artifactId) + " % " + quote(version) + optScope
+ def asSbt = quote(groupId) + " % " + quote(artifactId) + " % " + quote(version) + optScope + optClassifier
private lazy val optScope = scope map { " % " + quote(_) } getOrElse ""
+ private lazy val optClassifier = classifier map { " classifier " + quote(_) } getOrElse ""
private def quote(s: String) = "\"" + s + "\""
}
@@ -28,7 +29,8 @@ object Dependency {
groupId = (n \ "groupId").text,
artifactId = (n \ "artifactId").text,
version = (n \ "version").text,
- scope = Option((n \ "scope").text).filter(!_.isEmpty)
+ scope = Option((n \ "scope").text).filter(!_.isEmpty),
+ classifier = Option((n \ "classifier").text).filter(!_.isEmpty)
)
def fromPom(pom: NodeSeq) = pom \\ "dependency" map fromXml toList
@@ -9,7 +9,8 @@ class ConverterTest extends FlatSpec with ShouldMatchers {
result should be (
"""libraryDependencies ++= Seq(""" ::
""" "org.scala-lang" % "scala-library" % "2.8.1",""" ::
- """ "org.scalatest" % "scalatest" % "1.3" % "test"""" ::
+ """ "org.scalatest" % "scalatest" % "1.3" % "test",""" ::
+ """ "net.sf.json-lib" % "json-lib" % "1.1" classifier "jdk15"""" ::
""")""" ::
Nil
)
@@ -9,7 +9,8 @@ class DependencyTest extends FlatSpec with ShouldMatchers {
val dependencies = Dependency.fromPom(ExamplePoms.simplePom)
dependencies should be (List(
Dependency("org.scala-lang", "scala-library", "2.8.1"),
- Dependency("org.scalatest", "scalatest", "1.3", Some("test"))
+ Dependency("org.scalatest", "scalatest", "1.3", scope = Some("test")),
+ Dependency("net.sf.json-lib", "json-lib", "1.1", classifier = Some("jdk15"))
))
}
@@ -25,6 +25,14 @@ object ExamplePoms {
<version>1.3</version>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>net.sf.json-lib</groupId>
+ <artifactId>json-lib</artifactId>
+ <version>1.1</version>
+ <classifier>jdk15</classifier>
+ </dependency>
+
</dependencies>
</project>

0 comments on commit edc0949

Please sign in to comment.