mirror of https://github.com/sbt/sbt.git
expose launcher repositories
This commit is contained in:
parent
0b3ec05a81
commit
67db9cc743
|
|
@ -137,7 +137,7 @@ class ConfigurationParser
|
|||
val app = new Application(org, name, rev, main, components, toBoolean(crossVersioned), classpathExtra)
|
||||
(app, classifiers)
|
||||
}
|
||||
def getRepositories(m: LabelMap): List[Repository] =
|
||||
def getRepositories(m: LabelMap): List[xsbti.Repository] =
|
||||
{
|
||||
import Repository.{Ivy, Maven, Predefined}
|
||||
m.toList.map {
|
||||
|
|
|
|||
|
|
@ -89,6 +89,7 @@ class Launch private[xsbt](val bootDirectory: File, val lockBoot: Boolean, val i
|
|||
|
||||
def globalLock: xsbti.GlobalLock = Locks
|
||||
def ivyHome = ivyOptions.ivyHome.orNull
|
||||
def ivyRepositories = repositories.toArray
|
||||
|
||||
class JNAProvider extends Provider
|
||||
{
|
||||
|
|
@ -151,7 +152,7 @@ class Launch private[xsbt](val bootDirectory: File, val lockBoot: Boolean, val i
|
|||
}
|
||||
object Launcher
|
||||
{
|
||||
def apply(bootDirectory: File, repositories: List[Repository]): xsbti.Launcher =
|
||||
def apply(bootDirectory: File, repositories: List[xsbti.Repository]): xsbti.Launcher =
|
||||
apply(bootDirectory, IvyOptions(None, Classifiers(Nil, Nil), repositories))
|
||||
def apply(bootDirectory: File, ivyOptions: IvyOptions): xsbti.Launcher =
|
||||
apply(bootDirectory, ivyOptions, GetLocks.find)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ final case class LaunchConfiguration(scalaVersion: Value[String], ivyConfigurati
|
|||
LaunchConfiguration(new Explicit(newScalaVersion), ivyConfiguration.copy(classifiers = classifiers0), app.withVersion(new Explicit(newAppVersion)), boot, logging, appProperties)
|
||||
def map(f: File => File) = LaunchConfiguration(scalaVersion, ivyConfiguration, app.map(f), boot.map(f), logging, appProperties)
|
||||
}
|
||||
final case class IvyOptions(ivyHome: Option[File], classifiers: Classifiers, repositories: List[Repository])
|
||||
final case class IvyOptions(ivyHome: Option[File], classifiers: Classifiers, repositories: List[xsbti.Repository])
|
||||
|
||||
sealed trait Value[T]
|
||||
final class Explicit[T](val value: T) extends Value[T] {
|
||||
|
|
@ -61,25 +61,17 @@ object Application
|
|||
}
|
||||
}
|
||||
|
||||
sealed trait Repository
|
||||
object Repository
|
||||
{
|
||||
final case class Maven(id: String, url: URL) 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
|
||||
{
|
||||
val Local = value("local")
|
||||
val MavenLocal = value("maven-local")
|
||||
val MavenCentral = value("maven-central")
|
||||
val ScalaToolsReleases = value("scala-tools-releases")
|
||||
val ScalaToolsSnapshots = value("scala-tools-snapshots")
|
||||
def apply(s: String): Predefined = Predefined(toValue(s))
|
||||
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 Predefined(id: xsbti.Predefined) extends xsbti.PredefinedRepository
|
||||
object Predefined {
|
||||
def apply(s: String): Predefined = Predefined(xsbti.Predefined.toValue(s))
|
||||
}
|
||||
|
||||
def isMavenLocal(repo: Repository) = repo == Predefined(Predefined.MavenLocal)
|
||||
def defaults: List[Repository] = Predefined.elements.map(Predefined.apply).toList
|
||||
def isMavenLocal(repo: xsbti.Repository) = repo match { case p: xsbti.PredefinedRepository => p.id == xsbti.Predefined.MavenLocal; case _ => false }
|
||||
def defaults: List[xsbti.Repository] = xsbti.Predefined.values.map(Predefined.apply).toList
|
||||
}
|
||||
|
||||
final case class Search(tpe: Search.Value, paths: List[File])
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ sealed trait UpdateTarget { def tpe: String; def classifiers: List[String] }
|
|||
final class UpdateScala(val classifiers: List[String]) extends UpdateTarget { def tpe = "scala" }
|
||||
final class UpdateApp(val id: Application, val classifiers: List[String]) extends UpdateTarget { def tpe = "app" }
|
||||
|
||||
final class UpdateConfiguration(val bootDirectory: File, val ivyHome: Option[File], val scalaVersion: String, val repositories: List[Repository])
|
||||
final class UpdateConfiguration(val bootDirectory: File, val ivyHome: Option[File], val scalaVersion: String, val repositories: List[xsbti.Repository])
|
||||
|
||||
/** Ensures that the Scala and application jars exist for the given versions or else downloads them.*/
|
||||
final class Update(config: UpdateConfiguration)
|
||||
|
|
@ -229,7 +229,7 @@ final class Update(config: UpdateConfiguration)
|
|||
artifact.getQualifiedExtraAttributes.keys.exists(_.asInstanceOf[String] startsWith "m:")
|
||||
}
|
||||
// exclude the local Maven repository for Scala -SNAPSHOTs
|
||||
private def includeRepo(repo: Repository) = !(Repository.isMavenLocal(repo) && isSnapshot(scalaVersion) )
|
||||
private def includeRepo(repo: xsbti.Repository) = !(Repository.isMavenLocal(repo) && isSnapshot(scalaVersion) )
|
||||
private def isSnapshot(scalaVersion: String) = scalaVersion.endsWith(Snapshot)
|
||||
private[this] val Snapshot = "-SNAPSHOT"
|
||||
private[this] val ChangingPattern = ".*" + Snapshot
|
||||
|
|
@ -243,19 +243,20 @@ final class Update(config: UpdateConfiguration)
|
|||
settings.addRepositoryCacheManager(manager)
|
||||
settings.setDefaultRepositoryCacheManager(manager)
|
||||
}
|
||||
private def toIvyRepository(settings: IvySettings, repo: Repository) =
|
||||
private def toIvyRepository(settings: IvySettings, repo: xsbti.Repository) =
|
||||
{
|
||||
import Repository.{Ivy, Maven, Predefined}
|
||||
import Predefined._
|
||||
import xsbti.Predefined._
|
||||
repo match
|
||||
{
|
||||
case Maven(id, url) => mavenResolver(id, url.toString)
|
||||
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
|
||||
case Predefined(ScalaToolsReleases) => mavenResolver("Scala-Tools Maven2 Repository", "http://scala-tools.org/repo-releases")
|
||||
case Predefined(ScalaToolsSnapshots) => scalaSnapshots(scalaVersion)
|
||||
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 p: xsbti.PredefinedRepository => p.id match {
|
||||
case Local => localResolver(settings.getDefaultIvyUserDir.getAbsolutePath)
|
||||
case MavenLocal => mavenLocal
|
||||
case MavenCentral => mavenMainResolver
|
||||
case ScalaToolsReleases => mavenResolver("Scala-Tools Maven2 Repository", "http://scala-tools.org/repo-releases")
|
||||
case ScalaToolsSnapshots => scalaSnapshots(scalaVersion)
|
||||
}
|
||||
}
|
||||
}
|
||||
private def onDefaultRepositoryCacheManager(settings: IvySettings)(f: DefaultRepositoryCacheManager => Unit)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
package xsbti;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
public interface IvyRepository extends Repository
|
||||
{
|
||||
String id();
|
||||
URL url();
|
||||
String ivyPattern();
|
||||
String artifactPattern();
|
||||
}
|
||||
|
|
@ -10,6 +10,7 @@ public interface Launcher
|
|||
public ClassLoader topLoader();
|
||||
public GlobalLock globalLock();
|
||||
public File bootDirectory();
|
||||
public xsbti.Repository[] ivyRepositories();
|
||||
// null if none set
|
||||
public File ivyHome();
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package xsbti;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
public interface MavenRepository extends Repository
|
||||
{
|
||||
String id();
|
||||
URL url();
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package xsbti;
|
||||
|
||||
public enum Predefined
|
||||
{
|
||||
Local("local"),
|
||||
MavenLocal("maven-local"),
|
||||
MavenCentral("maven-central"),
|
||||
ScalaToolsReleases("scala-tools-releases"),
|
||||
ScalaToolsSnapshots("scala-tools-snapshots");
|
||||
|
||||
private final String label;
|
||||
private Predefined(String label) { this.label = label; }
|
||||
public String toString() { return label; }
|
||||
|
||||
public static Predefined toValue(String s)
|
||||
{
|
||||
for(Predefined p : values())
|
||||
if(s.equals(p.toString()))
|
||||
return p;
|
||||
|
||||
StringBuilder msg = new StringBuilder("Expected one of ");
|
||||
for(Predefined p : values())
|
||||
msg.append(p.toString()).append(", ");
|
||||
msg.append("got '").append(s).append("'.");
|
||||
throw new RuntimeException(msg.toString());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
package xsbti;
|
||||
|
||||
public interface PredefinedRepository extends Repository
|
||||
{
|
||||
Predefined id();
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
package xsbti;
|
||||
|
||||
public interface Repository {}
|
||||
Loading…
Reference in New Issue