mirror of https://github.com/sbt/sbt.git
allow specifying artifact/ivy patterns in [repositories] separately
This commit is contained in:
parent
1307292256
commit
9878d9b3ff
|
|
@ -143,9 +143,9 @@ class ConfigurationParser
|
|||
m.toList.map {
|
||||
case (key, None) => Predefined(key)
|
||||
case (key, Some(value)) =>
|
||||
val r = trim(value.split(",",2))
|
||||
val r = trim(value.split(",",3))
|
||||
val url = try { new URL(r(0)) } catch { case e: MalformedURLException => error("Invalid URL specified for '" + key + "': " + e.getMessage) }
|
||||
if(r.length == 2) Ivy(key, url, r(1)) else Maven(key, url)
|
||||
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)
|
||||
}
|
||||
}
|
||||
def getAppProperties(m: LabelMap): List[AppProperty] =
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ sealed trait Repository
|
|||
object Repository
|
||||
{
|
||||
final case class Maven(id: String, url: URL) extends Repository
|
||||
final case class Ivy(id: String, url: URL, pattern: String) extends Repository
|
||||
final case class Ivy(id: String, url: URL, ivyPattern: String, artifactPattern: String) extends Repository
|
||||
final case class Predefined(id: Predefined.Value) extends Repository
|
||||
|
||||
object Predefined extends Enumeration
|
||||
|
|
|
|||
|
|
@ -250,7 +250,7 @@ final class Update(config: UpdateConfiguration)
|
|||
repo match
|
||||
{
|
||||
case Maven(id, url) => mavenResolver(id, url.toString)
|
||||
case Ivy(id, url, pattern) => urlResolver(id, url.toString, pattern)
|
||||
case Ivy(id, url, ivyPattern, artifactPattern) => urlResolver(id, url.toString, ivyPattern, artifactPattern)
|
||||
case Predefined(Local) => localResolver(settings.getDefaultIvyUserDir.getAbsolutePath)
|
||||
case Predefined(MavenLocal) => mavenLocal
|
||||
case Predefined(MavenCentral) => mavenMainResolver
|
||||
|
|
@ -267,15 +267,16 @@ final class Update(config: UpdateConfiguration)
|
|||
}
|
||||
}
|
||||
/** Uses the pattern defined in BuildConfiguration to download sbt from Google code.*/
|
||||
private def urlResolver(id: String, base: String, pattern: String) =
|
||||
private def urlResolver(id: String, base: String, ivyPattern: String, artifactPattern: String) =
|
||||
{
|
||||
val resolver = new URLResolver
|
||||
resolver.setName(id)
|
||||
val adjusted = (if(base.endsWith("/")) base else (base + "/") ) + pattern
|
||||
resolver.addIvyPattern(adjusted)
|
||||
resolver.addArtifactPattern(adjusted)
|
||||
resolver.addIvyPattern(adjustPattern(base, ivyPattern))
|
||||
resolver.addArtifactPattern(adjustPattern(base, artifactPattern))
|
||||
resolver
|
||||
}
|
||||
private def adjustPattern(base: String, pattern: String): String =
|
||||
(if(base.endsWith("/") || base.isEmpty) base else (base + "/") ) + pattern
|
||||
private def mavenLocal = mavenResolver("Maven2 Local", "file://" + System.getProperty("user.home") + "/.m2/repository/")
|
||||
/** Creates a maven-style resolver.*/
|
||||
private def mavenResolver(name: String, root: String) =
|
||||
|
|
|
|||
Loading…
Reference in New Issue