mirror of https://github.com/sbt/sbt.git
configuration via ivysettings.xml: use URI instead of URL and make 'inter-project' resolver available for multi-project builds. ref #416
This commit is contained in:
parent
14dd139bb2
commit
c111fc1ae2
|
|
@ -6,6 +6,7 @@ package sbt
|
|||
import Resolver.PluginPattern
|
||||
|
||||
import java.io.File
|
||||
import java.net.URI
|
||||
import java.util.concurrent.Callable
|
||||
import java.util.{Collection, Collections => CS}
|
||||
import CS.singleton
|
||||
|
|
@ -65,7 +66,9 @@ final class IvySbt(val configuration: IvyConfiguration)
|
|||
CustomPomParser.registerDefault
|
||||
configuration match
|
||||
{
|
||||
case e: ExternalIvyConfiguration => is.load(e.url)
|
||||
case e: ExternalIvyConfiguration =>
|
||||
IvySbt.addResolvers(e.extraResolvers, is, configuration.log)
|
||||
IvySbt.loadURI(is, e.uri)
|
||||
case i: InlineIvyConfiguration =>
|
||||
is.setVariable("ivy.checksums", i.checksums mkString ",")
|
||||
i.paths.ivyHome foreach is.setDefaultIvyUserDir
|
||||
|
|
@ -198,6 +201,14 @@ private object IvySbt
|
|||
def defaultIvyConfiguration(project: File) = new File(project, DefaultIvyConfigFilename)
|
||||
def defaultPOM(project: File) = new File(project, DefaultMavenFilename)
|
||||
|
||||
def loadURI(is: IvySettings, uri: URI)
|
||||
{
|
||||
if(uri.getScheme == "file")
|
||||
is.load(new File(uri)) // IVY-1114
|
||||
else
|
||||
is.load(uri.toURL)
|
||||
}
|
||||
|
||||
/** Sets the resolvers for 'settings' to 'resolvers'. This is done by creating a new chain and making it the default.
|
||||
* 'other' is for resolvers that should be in a different chain. These are typically used for publishing or other actions. */
|
||||
private def setResolvers(settings: IvySettings, resolvers: Seq[Resolver], other: Seq[Resolver], localOnly: Boolean, log: Logger)
|
||||
|
|
@ -236,6 +247,13 @@ private object IvySbt
|
|||
}
|
||||
newDefault
|
||||
}
|
||||
def addResolvers(resolvers: Seq[Resolver], settings: IvySettings, log: Logger)
|
||||
{
|
||||
for(r <- resolvers) {
|
||||
log.debug("\t" + r)
|
||||
settings.addResolver(ConvertResolver(r)(settings, log))
|
||||
}
|
||||
}
|
||||
/** A hack to detect if the given artifact is an automatically generated request for a classifier,
|
||||
* as opposed to a user-initiated declaration. It relies on Ivy prefixing classifier with m:, while sbt uses e:.
|
||||
* Clearly, it would be better to have an explicit option in Ivy to control this.*/
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
package sbt
|
||||
|
||||
import java.io.File
|
||||
import java.net.URL
|
||||
import java.net.{URI,URL}
|
||||
import scala.xml.NodeSeq
|
||||
|
||||
final class IvyPaths(val baseDirectory: File, val ivyHome: Option[File])
|
||||
|
|
@ -28,20 +28,21 @@ final class InlineIvyConfiguration(val paths: IvyPaths, val resolvers: Seq[Resol
|
|||
def withBase(newBase: File) = new InlineIvyConfiguration(paths.withBase(newBase), resolvers, otherResolvers, moduleConfigurations, localOnly, lock, checksums, log)
|
||||
def changeResolvers(newResolvers: Seq[Resolver]) = new InlineIvyConfiguration(paths, newResolvers, otherResolvers, moduleConfigurations, localOnly, lock, checksums, log)
|
||||
}
|
||||
final class ExternalIvyConfiguration(val baseDirectory: File, val url: URL, val lock: Option[xsbti.GlobalLock], val log: Logger) extends IvyConfiguration
|
||||
final class ExternalIvyConfiguration(val baseDirectory: File, val uri: URI, val lock: Option[xsbti.GlobalLock], val extraResolvers: Seq[Resolver], val log: Logger) extends IvyConfiguration
|
||||
{
|
||||
type This = ExternalIvyConfiguration
|
||||
def withBase(newBase: File) = new ExternalIvyConfiguration(newBase, url, lock, log)
|
||||
def withBase(newBase: File) = new ExternalIvyConfiguration(newBase, uri, lock, extraResolvers, log)
|
||||
}
|
||||
object ExternalIvyConfiguration
|
||||
{
|
||||
def apply(baseDirectory: File, file: File, lock: Option[xsbti.GlobalLock], log: Logger) = new ExternalIvyConfiguration(baseDirectory, file.toURI.toURL, lock, log)
|
||||
def apply(baseDirectory: File, file: File, lock: Option[xsbti.GlobalLock], log: Logger) = new ExternalIvyConfiguration(baseDirectory, file.toURI, lock, Nil, log)
|
||||
}
|
||||
|
||||
object IvyConfiguration
|
||||
{
|
||||
/** Called to configure Ivy when inline resolvers are not specified.
|
||||
* This will configure Ivy with an 'ivy-settings.xml' file if there is one or else use default resolvers.*/
|
||||
@deprecated("Explicitly use either external or inline configuration.", "0.12.0")
|
||||
def apply(paths: IvyPaths, lock: Option[xsbti.GlobalLock], localOnly: Boolean, checksums: Seq[String], log: Logger): IvyConfiguration =
|
||||
{
|
||||
log.debug("Autodetecting configuration.")
|
||||
|
|
|
|||
Loading…
Reference in New Issue