Permalink
Browse files

XSBT-5: maven-style ivy repo support in the launcher config

Change-Id: I22c1ff126961d61d92e2e45a5b7eff329d3def90
Reviewed-on: https://gerrit.gilt.com/10950
Reviewed-by: Eric Bowman <ebowman@gilt.com>
Tested-by: Eric Bowman <ebowman@gilt.com>
  • Loading branch information...
1 parent 672550c commit 835ee0d1b380e3dba4cd21445136af0f5940501c @ebowman ebowman committed with Oct 25, 2012
View
@@ -81,6 +81,15 @@ final class Patterns(val ivyPatterns: Seq[String], val artifactPatterns: Seq[Str
private[sbt] def mavenStyle(): Patterns = Patterns(ivyPatterns, artifactPatterns, true)
private[sbt] def withIvys(patterns: Seq[String]): Patterns = Patterns(patterns ++ ivyPatterns, artifactPatterns, isMavenCompatible)
private[sbt] def withArtifacts(patterns: Seq[String]): Patterns = Patterns(ivyPatterns, patterns ++ artifactPatterns, isMavenCompatible)
+ override def toString = "Patterns(ivyPatterns=%s, artifactPatterns=%s, isMavenCompatible=%s)".format(ivyPatterns, artifactPatterns, isMavenCompatible)
+ override def equals(obj: Any): Boolean = {
+ obj match {
+ case other: Patterns =>
+ ivyPatterns == other.ivyPatterns && artifactPatterns == other.artifactPatterns && isMavenCompatible == other.isMavenCompatible
+ case _ => false
+ }
+ }
+ override def hashCode: Int = 617 * ivyPatterns.## + 37 * artifactPatterns.## + isMavenCompatible.hashCode
}
object Patterns
{
View
@@ -66,7 +66,7 @@ configuration ::= scala app repositories boot log app-properties
repository ::= ( predefinedRepository | customRepository ) nl
predefinedRepository ::= 'local' | 'maven-local' | 'maven-central' | 'scala-tools-releases' | 'scala-tools-snapshots'
- customRepository ::= label ':' url [',' pattern]
+ customRepository ::= label ':' url [[',' pattern] ',' pattern [',' 'mavenCompatible']]
property ::= label ':' propertyDefinition (',' propertyDefinition)* nl
propertyDefinition ::= mode '=' (set | prompt)
@@ -182,9 +182,16 @@ class ConfigurationParser
m.toList.map {
case (key, None) => Predefined(key)
case (key, Some(value)) =>
- val r = trim(substituteVariables(value).split(",",3))
+ val r = trim(substituteVariables(value).split(",",4))
val url = try { new URL(r(0)) } catch { case e: MalformedURLException => error("Invalid URL specified for '" + key + "': " + e.getMessage) }
- if(r.length == 3) Ivy(key, url, r(1), r(2)) else if(r.length == 2) Ivy(key, url, r(1), r(1)) else Maven(key, url)
+ r.tail match {
+ case both :: "mavenCompatible" :: Nil => Ivy(key, url, both, both, mavenCompatible=true)
+ case ivy :: art :: "mavenCompatible" :: Nil => Ivy(key, url, ivy, art, mavenCompatible=true)
+ case ivy :: art :: Nil => Ivy(key, url, ivy, art, mavenCompatible=false)
+ case both :: Nil => Ivy(key, url, both, both, mavenCompatible=false)
+ case Nil => Maven(key, url)
+ case _ => error("Could not parse %s: %s".format(key, value))
+ }
}
}
def getAppProperties(m: LabelMap): List[AppProperty] =
@@ -71,7 +71,7 @@ object Application
object Repository
{
final case class Maven(id: String, url: URL) extends xsbti.MavenRepository
- final case class Ivy(id: String, url: URL, ivyPattern: String, artifactPattern: String) extends xsbti.IvyRepository
+ final case class Ivy(id: String, url: URL, ivyPattern: String, artifactPattern: String, mavenCompatible: Boolean) extends xsbti.IvyRepository
final case class Predefined(id: xsbti.Predefined) extends xsbti.PredefinedRepository
object Predefined {
def apply(s: String): Predefined = Predefined(xsbti.Predefined.toValue(s))
View
@@ -291,7 +291,7 @@ final class Update(config: UpdateConfiguration)
repo match
{
case m: xsbti.MavenRepository => mavenResolver(m.id, m.url.toString)
- case i: xsbti.IvyRepository => urlResolver(i.id, i.url.toString, i.ivyPattern, i.artifactPattern)
+ case i: xsbti.IvyRepository => urlResolver(i.id, i.url.toString, i.ivyPattern, i.artifactPattern, i.mavenCompatible)
case p: xsbti.PredefinedRepository => p.id match {
case Local => localResolver(settings.getDefaultIvyUserDir.getAbsolutePath)
case MavenLocal => mavenLocal
@@ -310,12 +310,13 @@ final class Update(config: UpdateConfiguration)
}
}
/** Uses the pattern defined in BuildConfiguration to download sbt from Google code.*/
- private def urlResolver(id: String, base: String, ivyPattern: String, artifactPattern: String) =
+ private def urlResolver(id: String, base: String, ivyPattern: String, artifactPattern: String, mavenCompatible: Boolean) =
{
val resolver = new URLResolver
resolver.setName(id)
resolver.addIvyPattern(adjustPattern(base, ivyPattern))
resolver.addArtifactPattern(adjustPattern(base, artifactPattern))
+ resolver.setM2compatible(mavenCompatible)
resolver
}
private def adjustPattern(base: String, pattern: String): String =
@@ -8,4 +8,5 @@
URL url();
String ivyPattern();
String artifactPattern();
+ boolean mavenCompatible();
}
View
@@ -1217,7 +1217,7 @@ object Classpaths
repo match
{
case m: xsbti.MavenRepository => MavenRepository(m.id, m.url.toString)
- case i: xsbti.IvyRepository => Resolver.url(i.id, i.url)(Patterns(i.ivyPattern :: Nil, i.artifactPattern :: Nil, false))
+ case i: xsbti.IvyRepository => Resolver.url(i.id, i.url)(Patterns(i.ivyPattern :: Nil, i.artifactPattern :: Nil, i.mavenCompatible))
case p: xsbti.PredefinedRepository => p.id match {
case Predefined.Local => Resolver.defaultLocal
case Predefined.MavenLocal => Resolver.mavenLocal
@@ -106,7 +106,7 @@ by the following grammar. ``'nl'`` is a newline or end of file and
resources: "resources" ":" `path` ("," `path`)*
repository: ( `predefinedRepository` | `customRepository` ) `nl`
predefinedRepository: "local" | "maven-local" | "maven-central"
- customRepository: `label` ":" `url` [ ["," `ivyPattern`] "," `artifactPattern`]
+ customRepository: `label` ":" `url` [ ["," `ivyPattern`] "," `artifactPattern` [", mavenCompatible"]]
property: `label` ":" `propertyDefinition` ("," `propertyDefinition`)*
propertyDefinition: `mode` "=" (`set` | `prompt`)
mode: "quick" | "new" | "fill"

0 comments on commit 835ee0d

Please sign in to comment.