Skip to content

Commit

Permalink
use 'scalaVersion in update' for cross building, IvyScala.substituteC…
Browse files Browse the repository at this point in the history
…ross for generality. fixes #86

also, 'scalaVersion in artifactName` for the version to append to artifacts
  • Loading branch information
harrah committed Jul 17, 2011
1 parent b956b62 commit bcc3e12
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
10 changes: 4 additions & 6 deletions ivy/Ivy.scala
Expand Up @@ -290,11 +290,11 @@ private object IvySbt
}

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.ivyScala match { case None => m; case Some(is) => substituteCross(m, is.substituteCross) }
private def substituteCross(m: ModuleSettings, sub: ModuleID => ModuleID): 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 ec: EmptyConfiguration => ec.copy(module = sub(ec.module))
case ic: InlineConfiguration => ic.copy(module = sub(ic.module), dependencies = ic.dependencies map sub)
case _ => m
}
def crossName(name: String, cross: String): String =
Expand All @@ -303,8 +303,6 @@ private object IvySbt
a.copy(name = crossName(a.name, cross))
def substituteCrossA(as: Seq[Artifact], cross: String): Seq[Artifact] =
as.map(art => substituteCross(art, cross))
def substituteCrossM(ms: Seq[ModuleID], cross: String): Seq[ModuleID] =
ms.map(m => substituteCross(m, cross))
def substituteCross(m: ModuleID, cross: String): ModuleID =
if(m.crossVersion)
m.copy(name = crossName(m.name, cross), explicitArtifacts = substituteCrossA(m.explicitArtifacts, cross))
Expand Down
4 changes: 2 additions & 2 deletions ivy/IvyScala.scala
Expand Up @@ -22,10 +22,10 @@ object ScalaArtifacts

import ScalaArtifacts._

final case class IvyScala(scalaVersion: String, configurations: Iterable[Configuration], checkExplicit: Boolean, filterImplicit: Boolean, overrideScalaVersion: Boolean)
final case class IvyScala(scalaVersion: String, configurations: Iterable[Configuration], checkExplicit: Boolean, filterImplicit: Boolean, overrideScalaVersion: Boolean, substituteCross: ModuleID => ModuleID)
{
// otherwise, Ivy produces the error: "impossible to get artifacts when data has not been loaded"
// which may be related to sbt's custom conflict manager, to IVY-987, or both
// which may be related to sbt's custom conflict manager (now removed), to IVY-987, or both
assert(if(overrideScalaVersion) checkExplicit else true, "Explicit Scala version checking cannot be disabled when forcing the Scala version.")
}
private object IvyScala
Expand Down
6 changes: 4 additions & 2 deletions main/Defaults.scala
Expand Up @@ -326,7 +326,7 @@ object Defaults extends BuildCommon
def collectFiles(dirs: ScopedTaskable[Seq[File]], filter: ScopedTaskable[FileFilter], excludes: ScopedTaskable[FileFilter]): Initialize[Task[Seq[File]]] =
(dirs, filter, excludes) map { (d,f,excl) => d.descendentsExcept(f,excl).get }

def artifactPathSetting(art: ScopedSetting[Artifact]) = (crossTarget, projectID, art, scalaVersion, artifactName) { (t, module, a, sv, toString) => t / toString(sv, module, a) asFile }
def artifactPathSetting(art: ScopedSetting[Artifact]) = (crossTarget, projectID, art, scalaVersion in artifactName, artifactName) { (t, module, a, sv, toString) => t / toString(sv, module, a) asFile }

def pairID[A,B] = (a: A, b: B) => (a,b)
def packageTasks(key: TaskKey[File], mappingsTask: Initialize[Task[Seq[(File,String)]]]) =
Expand Down Expand Up @@ -611,7 +611,9 @@ object Classpaths
ivyLoggingLevel in GlobalScope :== UpdateLogging.Quiet,
ivyXML in GlobalScope :== NodeSeq.Empty,
ivyValidate in GlobalScope :== false,
ivyScala <<= ivyScala or (scalaHome, scalaVersion)((sh,v) => Some(new IvyScala(v, Nil, filterImplicit = true, checkExplicit = true, overrideScalaVersion = sh.isEmpty))),
ivyScala <<= ivyScala or (scalaHome, scalaVersion, scalaVersion in update) { (sh,v,vu) =>
Some(new IvyScala(v, Nil, filterImplicit = true, checkExplicit = true, overrideScalaVersion = sh.isEmpty, substituteCross = x => IvySbt.substituteCross(x, vu)))
},
moduleConfigurations in GlobalScope :== Nil,
publishTo in GlobalScope :== None,
artifactPath in makePom <<= artifactPathSetting(artifact in makePom),
Expand Down

0 comments on commit bcc3e12

Please sign in to comment.