mirror of https://github.com/sbt/sbt.git
Inline Ivy module configurations
git-svn-id: https://simple-build-tool.googlecode.com/svn/trunk@1047 d89573ee-9141-11dd-94d4-bdf5e562f29c
This commit is contained in:
parent
2f684fe166
commit
958310a105
|
|
@ -1,3 +1,4 @@
|
||||||
|
<!-- to be replace by inline ModuleConfigurations when 0.5.5 is released -->
|
||||||
<ivysettings>
|
<ivysettings>
|
||||||
<settings defaultResolver="sbt-chain"/>
|
<settings defaultResolver="sbt-chain"/>
|
||||||
<include url="${ivy.default.settings.dir}/ivysettings-public.xml"/>
|
<include url="${ivy.default.settings.dir}/ivysettings-public.xml"/>
|
||||||
|
|
|
||||||
|
|
@ -232,7 +232,7 @@ trait BasicManagedProject extends ManagedProject with ReflectiveManagedProject w
|
||||||
/** The dependency manager that represents inline declarations. The default manager packages the information
|
/** The dependency manager that represents inline declarations. The default manager packages the information
|
||||||
* from 'ivyXML', 'projectID', 'repositories', and 'libraryDependencies' and does not typically need to be
|
* from 'ivyXML', 'projectID', 'repositories', and 'libraryDependencies' and does not typically need to be
|
||||||
* be overridden. */
|
* be overridden. */
|
||||||
def manager = new SimpleManager(ivyXML, true, projectID, repositories.toSeq, ivyConfigurations, defaultConfiguration, libraryDependencies.toList: _*)
|
def manager = new SimpleManager(ivyXML, true, projectID, repositories.toSeq, moduleConfigurations.toSeq, ivyConfigurations, defaultConfiguration, libraryDependencies.toList: _*)
|
||||||
|
|
||||||
/** The pattern for Ivy to use when retrieving dependencies into the local project. Classpath management
|
/** The pattern for Ivy to use when retrieving dependencies into the local project. Classpath management
|
||||||
* depends on the first directory being [conf] and the extension being [ext].*/
|
* depends on the first directory being [conf] and the extension being [ext].*/
|
||||||
|
|
@ -607,6 +607,17 @@ trait ReflectiveRepositories extends Project
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
def reflectiveRepositories: Map[String, Resolver] = Reflective.reflectiveMappings[Resolver](this)
|
def reflectiveRepositories: Map[String, Resolver] = Reflective.reflectiveMappings[Resolver](this)
|
||||||
|
|
||||||
|
def moduleConfigurations: Set[ModuleConfiguration] =
|
||||||
|
{
|
||||||
|
val reflective = Set[ModuleConfiguration](reflectiveModuleConfigurations.values.toList: _*)
|
||||||
|
info.parent match
|
||||||
|
{
|
||||||
|
case Some(p: ReflectiveRepositories) => p.moduleConfigurations ++ reflective
|
||||||
|
case None => reflective
|
||||||
|
}
|
||||||
|
}
|
||||||
|
def reflectiveModuleConfigurations: Map[String, ModuleConfiguration] = Reflective.reflectiveMappings[ModuleConfiguration](this)
|
||||||
}
|
}
|
||||||
|
|
||||||
trait ReflectiveManagedProject extends ReflectiveProject with ReflectiveArtifacts with ReflectiveRepositories with ReflectiveLibraryDependencies with ReflectiveConfigurations
|
trait ReflectiveManagedProject extends ReflectiveProject with ReflectiveArtifacts with ReflectiveRepositories with ReflectiveLibraryDependencies with ReflectiveConfigurations
|
||||||
|
|
@ -11,7 +11,7 @@ import scala.collection.mutable.HashSet
|
||||||
import Artifact.{defaultExtension, defaultType}
|
import Artifact.{defaultExtension, defaultType}
|
||||||
|
|
||||||
import org.apache.ivy.{core, plugins, util, Ivy}
|
import org.apache.ivy.{core, plugins, util, Ivy}
|
||||||
import core.LogOptions
|
import core.{IvyPatternHelper, LogOptions}
|
||||||
import core.cache.DefaultRepositoryCacheManager
|
import core.cache.DefaultRepositoryCacheManager
|
||||||
import core.deliver.DeliverOptions
|
import core.deliver.DeliverOptions
|
||||||
import core.install.InstallOptions
|
import core.install.InstallOptions
|
||||||
|
|
@ -200,12 +200,13 @@ object ManageDependencies
|
||||||
case sm: SbtManager =>
|
case sm: SbtManager =>
|
||||||
{
|
{
|
||||||
import sm._
|
import sm._
|
||||||
if(resolvers.isEmpty && autodetectUnspecified)
|
if(resolvers.isEmpty && moduleConfigurations.isEmpty && autodetectUnspecified)
|
||||||
autodetectConfiguration()
|
autodetectConfiguration()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
log.debug("Using inline repositories.")
|
log.debug("Using inline repositories.")
|
||||||
configureDefaults(withDefaultResolvers(resolvers))
|
configureDefaults(withDefaultResolvers(resolvers))
|
||||||
|
setModuleConfigurations(settings, moduleConfigurations)
|
||||||
}
|
}
|
||||||
if(autodetect)
|
if(autodetect)
|
||||||
autodetectDependencies(toID(module), true)
|
autodetectDependencies(toID(module), true)
|
||||||
|
|
@ -563,6 +564,20 @@ object ManageDependencies
|
||||||
moduleID.setModuleArtifact(artifact)
|
moduleID.setModuleArtifact(artifact)
|
||||||
moduleID.check()
|
moduleID.check()
|
||||||
}
|
}
|
||||||
|
private def setModuleConfigurations(settings: IvySettings, moduleConfigurations: Seq[ModuleConfiguration])
|
||||||
|
{
|
||||||
|
val existing = settings.getResolverNames
|
||||||
|
for(moduleConf <- moduleConfigurations)
|
||||||
|
{
|
||||||
|
import moduleConf._
|
||||||
|
import IvyPatternHelper._
|
||||||
|
import PatternMatcher._
|
||||||
|
if(!existing.contains(resolver.name))
|
||||||
|
settings.addResolver(ConvertResolver(resolver))
|
||||||
|
val attributes = javaMap(Map(MODULE_KEY -> name, ORGANISATION_KEY -> organization, REVISION_KEY -> revision))
|
||||||
|
settings.addModuleConfiguration(attributes, settings.getMatcher(EXACT_OR_REGEXP), resolver.name, null, null, null)
|
||||||
|
}
|
||||||
|
}
|
||||||
/** Sets the resolvers for 'settings' to 'resolvers'. This is done by creating a new chain and making it the default. */
|
/** Sets the resolvers for 'settings' to 'resolvers'. This is done by creating a new chain and making it the default. */
|
||||||
private def setResolvers(settings: IvySettings, resolvers: Seq[Resolver], log: Logger)
|
private def setResolvers(settings: IvySettings, resolvers: Seq[Resolver], log: Logger)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ sealed trait SbtManager extends Manager
|
||||||
def autodetect: Boolean
|
def autodetect: Boolean
|
||||||
def module: ModuleID
|
def module: ModuleID
|
||||||
def resolvers: Seq[Resolver]
|
def resolvers: Seq[Resolver]
|
||||||
|
def moduleConfigurations: Seq[ModuleConfiguration]
|
||||||
def dependencies: Iterable[ModuleID]
|
def dependencies: Iterable[ModuleID]
|
||||||
def autodetectUnspecified: Boolean
|
def autodetectUnspecified: Boolean
|
||||||
def dependenciesXML: NodeSeq
|
def dependenciesXML: NodeSeq
|
||||||
|
|
@ -36,8 +37,9 @@ sealed trait SbtManager extends Manager
|
||||||
def defaultConfiguration: Option[Configuration]
|
def defaultConfiguration: Option[Configuration]
|
||||||
}
|
}
|
||||||
final class SimpleManager private[sbt] (val dependenciesXML: NodeSeq, val autodetectUnspecified: Boolean,
|
final class SimpleManager private[sbt] (val dependenciesXML: NodeSeq, val autodetectUnspecified: Boolean,
|
||||||
val module: ModuleID, val resolvers: Seq[Resolver], explicitConfigurations: Iterable[Configuration],
|
val module: ModuleID, val resolvers: Seq[Resolver], val moduleConfigurations: Seq[ModuleConfiguration],
|
||||||
val defaultConfiguration: Option[Configuration], val dependencies: ModuleID*) extends SbtManager
|
explicitConfigurations: Iterable[Configuration], val defaultConfiguration: Option[Configuration],
|
||||||
|
val dependencies: ModuleID*) extends SbtManager
|
||||||
{
|
{
|
||||||
def autodetect = dependencies.isEmpty && dependenciesXML.isEmpty && module.explicitArtifacts.isEmpty && explicitConfigurations.isEmpty && autodetectUnspecified
|
def autodetect = dependencies.isEmpty && dependenciesXML.isEmpty && module.explicitArtifacts.isEmpty && explicitConfigurations.isEmpty && autodetectUnspecified
|
||||||
def configurations =
|
def configurations =
|
||||||
|
|
@ -53,7 +55,12 @@ final class SimpleManager private[sbt] (val dependenciesXML: NodeSeq, val autode
|
||||||
else
|
else
|
||||||
explicitConfigurations
|
explicitConfigurations
|
||||||
}
|
}
|
||||||
|
final case class ModuleConfiguration(organization: String, name: String, revision: String, resolver: Resolver) extends NotNull
|
||||||
|
object ModuleConfiguration
|
||||||
|
{
|
||||||
|
def apply(org: String, resolver: Resolver): ModuleConfiguration = apply(org, "*", "*", resolver)
|
||||||
|
def apply(org: String, name: String, resolver: Resolver): ModuleConfiguration = ModuleConfiguration(org, name, "*", resolver)
|
||||||
|
}
|
||||||
final case class ModuleID(organization: String, name: String, revision: String, configurations: Option[String], isChanging: Boolean, isTransitive: Boolean, explicitArtifacts: Seq[Artifact], extraAttributes: Map[String,String]) extends NotNull
|
final case class ModuleID(organization: String, name: String, revision: String, configurations: Option[String], isChanging: Boolean, isTransitive: Boolean, explicitArtifacts: Seq[Artifact], extraAttributes: Map[String,String]) extends NotNull
|
||||||
{
|
{
|
||||||
override def toString = organization + ":" + name + ":" + revision
|
override def toString = organization + ":" + name + ":" + revision
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue