2009-08-16 20:29:08 +02:00
|
|
|
/* sbt -- Simple Build Tool
|
2010-02-08 05:45:19 +01:00
|
|
|
* Copyright 2008, 2009, 2010 Mark Harrah
|
2009-08-16 20:29:08 +02:00
|
|
|
*/
|
2010-01-16 01:05:23 +01:00
|
|
|
package sbt
|
2009-08-16 20:29:08 +02:00
|
|
|
|
|
|
|
|
import java.io.File
|
2012-04-12 04:40:45 +02:00
|
|
|
import java.net.{URI,URL}
|
2011-05-18 02:09:20 +02:00
|
|
|
import scala.xml.NodeSeq
|
2009-08-16 20:29:08 +02:00
|
|
|
|
2011-04-14 01:01:22 +02:00
|
|
|
final class IvyPaths(val baseDirectory: File, val ivyHome: Option[File])
|
2010-01-30 02:31:07 +01:00
|
|
|
{
|
2011-04-14 01:01:22 +02:00
|
|
|
def withBase(newBaseDirectory: File) = new IvyPaths(newBaseDirectory, ivyHome)
|
2010-01-30 02:31:07 +01:00
|
|
|
}
|
2010-10-26 23:59:24 +02:00
|
|
|
sealed trait IvyConfiguration
|
2010-01-16 01:05:23 +01:00
|
|
|
{
|
2010-01-30 02:31:07 +01:00
|
|
|
type This <: IvyConfiguration
|
2010-01-29 01:31:04 +01:00
|
|
|
def lock: Option[xsbti.GlobalLock]
|
2010-01-16 01:05:23 +01:00
|
|
|
def baseDirectory: File
|
2010-09-04 14:19:58 +02:00
|
|
|
def log: Logger
|
2010-01-30 02:31:07 +01:00
|
|
|
def withBase(newBaseDirectory: File): This
|
2010-01-16 01:05:23 +01:00
|
|
|
}
|
2010-03-04 06:07:12 +01:00
|
|
|
final class InlineIvyConfiguration(val paths: IvyPaths, val resolvers: Seq[Resolver], val otherResolvers: Seq[Resolver],
|
2010-05-03 01:15:01 +02:00
|
|
|
val moduleConfigurations: Seq[ModuleConfiguration], val localOnly: Boolean, val lock: Option[xsbti.GlobalLock],
|
2012-08-28 17:55:24 +02:00
|
|
|
val checksums: Seq[String], val resolutionCacheDir: Option[File], val log: Logger) extends IvyConfiguration
|
2010-01-16 01:05:23 +01:00
|
|
|
{
|
2012-08-28 17:55:24 +02:00
|
|
|
@deprecated("Use the variant that accepts the resolution cache location.", "0.13.0")
|
|
|
|
|
def this(paths: IvyPaths, resolvers: Seq[Resolver], otherResolvers: Seq[Resolver],
|
|
|
|
|
moduleConfigurations: Seq[ModuleConfiguration], localOnly: Boolean, lock: Option[xsbti.GlobalLock],
|
|
|
|
|
checksums: Seq[String], log: Logger) =
|
|
|
|
|
this(paths, resolvers, otherResolvers, moduleConfigurations, localOnly, lock, checksums, None, log)
|
|
|
|
|
|
2010-01-30 02:31:07 +01:00
|
|
|
type This = InlineIvyConfiguration
|
2010-01-16 01:05:23 +01:00
|
|
|
def baseDirectory = paths.baseDirectory
|
2012-08-28 17:55:24 +02:00
|
|
|
def withBase(newBase: File) = new InlineIvyConfiguration(paths.withBase(newBase), resolvers, otherResolvers, moduleConfigurations, localOnly, lock, checksums, resolutionCacheDir, log)
|
|
|
|
|
def changeResolvers(newResolvers: Seq[Resolver]) = new InlineIvyConfiguration(paths, newResolvers, otherResolvers, moduleConfigurations, localOnly, lock, checksums, resolutionCacheDir, log)
|
2010-01-16 01:05:23 +01:00
|
|
|
}
|
2012-04-12 04:40:45 +02:00
|
|
|
final class ExternalIvyConfiguration(val baseDirectory: File, val uri: URI, val lock: Option[xsbti.GlobalLock], val extraResolvers: Seq[Resolver], val log: Logger) extends IvyConfiguration
|
2010-01-30 02:31:07 +01:00
|
|
|
{
|
|
|
|
|
type This = ExternalIvyConfiguration
|
2012-04-12 04:40:45 +02:00
|
|
|
def withBase(newBase: File) = new ExternalIvyConfiguration(newBase, uri, lock, extraResolvers, log)
|
2012-04-09 05:22:15 +02:00
|
|
|
}
|
|
|
|
|
object ExternalIvyConfiguration
|
|
|
|
|
{
|
2012-04-12 04:40:45 +02:00
|
|
|
def apply(baseDirectory: File, file: File, lock: Option[xsbti.GlobalLock], log: Logger) = new ExternalIvyConfiguration(baseDirectory, file.toURI, lock, Nil, log)
|
2010-01-30 02:31:07 +01:00
|
|
|
}
|
2010-01-16 01:05:23 +01:00
|
|
|
|
|
|
|
|
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.*/
|
2012-04-12 04:40:45 +02:00
|
|
|
@deprecated("Explicitly use either external or inline configuration.", "0.12.0")
|
2011-04-16 00:25:54 +02:00
|
|
|
def apply(paths: IvyPaths, lock: Option[xsbti.GlobalLock], localOnly: Boolean, checksums: Seq[String], log: Logger): IvyConfiguration =
|
2010-01-16 01:05:23 +01:00
|
|
|
{
|
|
|
|
|
log.debug("Autodetecting configuration.")
|
|
|
|
|
val defaultIvyConfigFile = IvySbt.defaultIvyConfiguration(paths.baseDirectory)
|
|
|
|
|
if(defaultIvyConfigFile.canRead)
|
2012-04-09 05:22:15 +02:00
|
|
|
ExternalIvyConfiguration(paths.baseDirectory, defaultIvyConfigFile, lock, log)
|
2010-01-16 01:05:23 +01:00
|
|
|
else
|
2012-08-28 17:55:24 +02:00
|
|
|
new InlineIvyConfiguration(paths, Resolver.withDefaultResolvers(Nil), Nil, Nil, localOnly, lock, checksums, None, log)
|
2010-01-16 01:05:23 +01:00
|
|
|
}
|
|
|
|
|
}
|
2009-08-16 20:29:08 +02:00
|
|
|
|
2010-10-26 23:59:24 +02:00
|
|
|
sealed trait ModuleSettings
|
2009-08-16 20:29:08 +02:00
|
|
|
{
|
2009-09-09 05:13:30 +02:00
|
|
|
def validate: Boolean
|
|
|
|
|
def ivyScala: Option[IvyScala]
|
2010-01-16 01:05:23 +01:00
|
|
|
def noScala: ModuleSettings
|
2009-08-16 20:29:08 +02:00
|
|
|
}
|
2011-02-15 00:57:10 +01:00
|
|
|
final case class IvyFileConfiguration(file: File, ivyScala: Option[IvyScala], validate: Boolean) extends ModuleSettings
|
2010-01-16 01:05:23 +01:00
|
|
|
{
|
2011-02-15 00:57:10 +01:00
|
|
|
def noScala = copy(ivyScala = None)
|
2010-01-16 01:05:23 +01:00
|
|
|
}
|
2011-02-15 00:57:10 +01:00
|
|
|
final case class PomConfiguration(file: File, ivyScala: Option[IvyScala], validate: Boolean) extends ModuleSettings
|
2010-01-16 01:05:23 +01:00
|
|
|
{
|
2011-02-15 00:57:10 +01:00
|
|
|
def noScala = copy(ivyScala = None)
|
2010-01-16 01:05:23 +01:00
|
|
|
}
|
2012-02-15 03:59:12 +01:00
|
|
|
final case class InlineConfiguration(module: ModuleID, moduleInfo: ModuleInfo, dependencies: Seq[ModuleID], overrides: Set[ModuleID] = Set.empty, ivyXML: NodeSeq = NodeSeq.Empty, configurations: Seq[Configuration] = Nil, defaultConfiguration: Option[Configuration] = None, ivyScala: Option[IvyScala] = None, validate: Boolean = false) extends ModuleSettings
|
2010-01-16 01:05:23 +01:00
|
|
|
{
|
2011-02-15 00:57:10 +01:00
|
|
|
def withConfigurations(configurations: Seq[Configuration]) = copy(configurations = configurations)
|
|
|
|
|
def noScala = copy(ivyScala = None)
|
2010-01-16 01:05:23 +01:00
|
|
|
}
|
2011-07-31 19:47:35 +02:00
|
|
|
final case class EmptyConfiguration(module: ModuleID, moduleInfo: ModuleInfo, ivyScala: Option[IvyScala], validate: Boolean) extends ModuleSettings
|
2010-01-16 01:05:23 +01:00
|
|
|
{
|
2011-02-15 00:57:10 +01:00
|
|
|
def noScala = copy(ivyScala = None)
|
2010-01-16 01:05:23 +01:00
|
|
|
}
|
2009-09-09 05:13:30 +02:00
|
|
|
object InlineConfiguration
|
2009-08-16 20:29:08 +02:00
|
|
|
{
|
|
|
|
|
def configurations(explicitConfigurations: Iterable[Configuration], defaultConfiguration: Option[Configuration]) =
|
|
|
|
|
if(explicitConfigurations.isEmpty)
|
|
|
|
|
{
|
|
|
|
|
defaultConfiguration match
|
|
|
|
|
{
|
|
|
|
|
case Some(Configurations.DefaultIvyConfiguration) => Configurations.Default :: Nil
|
|
|
|
|
case Some(Configurations.DefaultMavenConfiguration) => Configurations.defaultMavenConfigurations
|
|
|
|
|
case _ => Nil
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
explicitConfigurations
|
2009-09-09 05:13:30 +02:00
|
|
|
}
|
2009-09-27 20:39:26 +02:00
|
|
|
object ModuleSettings
|
2009-09-09 05:13:30 +02:00
|
|
|
{
|
2011-08-16 23:28:53 +02:00
|
|
|
def apply(ivyScala: Option[IvyScala], validate: Boolean, module: => ModuleID, moduleInfo: => ModuleInfo)(baseDirectory: File, log: Logger): ModuleSettings =
|
2009-09-09 05:13:30 +02:00
|
|
|
{
|
|
|
|
|
log.debug("Autodetecting dependencies.")
|
|
|
|
|
val defaultPOMFile = IvySbt.defaultPOM(baseDirectory)
|
|
|
|
|
if(defaultPOMFile.canRead)
|
|
|
|
|
new PomConfiguration(defaultPOMFile, ivyScala, validate)
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
val defaultIvy = IvySbt.defaultIvyFile(baseDirectory)
|
|
|
|
|
if(defaultIvy.canRead)
|
|
|
|
|
new IvyFileConfiguration(defaultIvy, ivyScala, validate)
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
log.warn("No dependency configuration found, using defaults.")
|
2011-07-31 19:47:35 +02:00
|
|
|
new EmptyConfiguration(module, moduleInfo, ivyScala, validate)
|
2009-09-09 05:13:30 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-07-31 19:47:35 +02:00
|
|
|
}
|