mirror of https://github.com/sbt/sbt.git
implement %%
This commit is contained in:
parent
83cb152fd7
commit
dcd24f5dc4
|
|
@ -86,8 +86,9 @@ final class IvySbt(val configuration: IvyConfiguration)
|
|||
finally { ivy.popContext() }
|
||||
}
|
||||
|
||||
final class Module(val moduleSettings: ModuleSettings)
|
||||
final class Module(rawModuleSettings: ModuleSettings)
|
||||
{
|
||||
val moduleSettings: ModuleSettings = IvySbt.substituteCross(rawModuleSettings)
|
||||
def owner = IvySbt.this
|
||||
def logger = configuration.log
|
||||
def withModule[T](f: (Ivy,DefaultModuleDescriptor,String) => T): T =
|
||||
|
|
@ -250,6 +251,29 @@ private object IvySbt
|
|||
import m._
|
||||
ModuleRevisionId.newInstance(organization, name, revision, javaMap(extraAttributes))
|
||||
}
|
||||
|
||||
private def substituteCross(m: ModuleSettings): ModuleSettings =
|
||||
m.ivyScala match { case None => m; case Some(is) => substituteCross(m, is.scalaVersion) }
|
||||
private def substituteCross(m: ModuleSettings, cross: String): ModuleSettings =
|
||||
m match {
|
||||
case ec: EmptyConfiguration => ec.copy(module = substituteCross(ec.module, cross))
|
||||
case ic: InlineConfiguration => ic.copy(module = substituteCross(ic.module, cross), dependencies = substituteCrossM(ic.dependencies, cross))
|
||||
case _ => m
|
||||
}
|
||||
private def crossName(name: String, cross: String): String =
|
||||
name + "_" + cross
|
||||
private def substituteCross(a: Artifact, cross: String): Artifact =
|
||||
a.copy(name = crossName(a.name, cross))
|
||||
private def substituteCrossA(as: Seq[Artifact], cross: String): Seq[Artifact] =
|
||||
as.map(art => substituteCross(art, cross))
|
||||
private def substituteCrossM(ms: Seq[ModuleID], cross: String): Seq[ModuleID] =
|
||||
ms.map(m => substituteCross(m, cross))
|
||||
private def substituteCross(m: ModuleID, cross: String): ModuleID =
|
||||
if(m.crossVersion)
|
||||
m.copy(name = crossName(m.name, cross), crossVersion = false, explicitArtifacts = substituteCrossA(m.explicitArtifacts, cross))
|
||||
else
|
||||
m
|
||||
|
||||
private def toIvyArtifact(moduleID: ModuleDescriptor, a: Artifact, configurations: Iterable[String]): MDArtifact =
|
||||
{
|
||||
val artifact = new MDArtifact(moduleID, a.name, a.`type`, a.extension, null, extra(a))
|
||||
|
|
|
|||
|
|
@ -54,25 +54,24 @@ sealed trait ModuleSettings
|
|||
def ivyScala: Option[IvyScala]
|
||||
def noScala: ModuleSettings
|
||||
}
|
||||
final class IvyFileConfiguration(val file: File, val ivyScala: Option[IvyScala], val validate: Boolean) extends ModuleSettings
|
||||
final case class IvyFileConfiguration(file: File, ivyScala: Option[IvyScala], validate: Boolean) extends ModuleSettings
|
||||
{
|
||||
def noScala = new IvyFileConfiguration(file, None, validate)
|
||||
def noScala = copy(ivyScala = None)
|
||||
}
|
||||
final class PomConfiguration(val file: File, val ivyScala: Option[IvyScala], val validate: Boolean) extends ModuleSettings
|
||||
final case class PomConfiguration(file: File, ivyScala: Option[IvyScala], validate: Boolean) extends ModuleSettings
|
||||
{
|
||||
def noScala = new PomConfiguration(file, None, validate)
|
||||
def noScala = copy(ivyScala = None)
|
||||
}
|
||||
final class InlineConfiguration(val module: ModuleID, val dependencies: Seq[ModuleID], val ivyXML: NodeSeq,
|
||||
val configurations: Seq[Configuration], val defaultConfiguration: Option[Configuration], val ivyScala: Option[IvyScala],
|
||||
val validate: Boolean) extends ModuleSettings
|
||||
final case class InlineConfiguration(module: ModuleID, dependencies: Seq[ModuleID], ivyXML: NodeSeq,
|
||||
configurations: Seq[Configuration], defaultConfiguration: Option[Configuration], ivyScala: Option[IvyScala],
|
||||
validate: Boolean) extends ModuleSettings
|
||||
{
|
||||
def withConfigurations(configurations: Seq[Configuration]) =
|
||||
new InlineConfiguration(module, dependencies, ivyXML, configurations, defaultConfiguration, ivyScala, validate)
|
||||
def noScala = new InlineConfiguration(module, dependencies, ivyXML, configurations, defaultConfiguration, None, validate)
|
||||
def withConfigurations(configurations: Seq[Configuration]) = copy(configurations = configurations)
|
||||
def noScala = copy(ivyScala = None)
|
||||
}
|
||||
final class EmptyConfiguration(val module: ModuleID, val ivyScala: Option[IvyScala], val validate: Boolean) extends ModuleSettings
|
||||
final case class EmptyConfiguration(module: ModuleID, ivyScala: Option[IvyScala], validate: Boolean) extends ModuleSettings
|
||||
{
|
||||
def noScala = new EmptyConfiguration(module, None, validate)
|
||||
def noScala = copy(ivyScala = None)
|
||||
}
|
||||
object InlineConfiguration
|
||||
{
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ import org.apache.ivy.util.url.CredentialsStore
|
|||
final case class ModuleID(organization: String, name: String, revision: String, configurations: Option[String] = None, isChanging: Boolean = false, isTransitive: Boolean = true, explicitArtifacts: Seq[Artifact] = Nil, extraAttributes: Map[String,String] = Map.empty, crossVersion: Boolean = false)
|
||||
{
|
||||
override def toString = organization + ":" + name + ":" + revision
|
||||
// () required for chaining
|
||||
def cross(v: Boolean) = copy(crossVersion = v)
|
||||
// () required for chaining
|
||||
def notTransitive() = intransitive()
|
||||
def intransitive() = copy(isTransitive = false)
|
||||
def changing() = copy(isChanging = true)
|
||||
|
|
|
|||
|
|
@ -511,7 +511,7 @@ object Classpaths
|
|||
IvyLoggingLevel in GlobalScope :== UpdateLogging.Quiet,
|
||||
IvyXML in GlobalScope :== NodeSeq.Empty,
|
||||
IvyValidate in GlobalScope :== false,
|
||||
IvyScalaConfig in GlobalScope :== None,
|
||||
IvyScalaConfig in GlobalScope <<= ScalaVersion(v => Some(new IvyScala(v, Nil, false, false))),
|
||||
ModuleConfigurations in GlobalScope :== Nil,
|
||||
PublishTo in GlobalScope :== None,
|
||||
PomFile <<= (Target, Version, ModuleName)( (target, version, module) => target / (module + "-" + version + ".pom") ),
|
||||
|
|
|
|||
Loading…
Reference in New Issue