mirror of https://github.com/sbt/sbt.git
Merge pull request #361 from vigdorchik/add_ivy_force
Mirror ivy \'force\' attribute in sbt.
This commit is contained in:
commit
baaf75b08a
|
|
@ -404,7 +404,7 @@ private object IvySbt
|
|||
{
|
||||
for(dependency <- dependencies)
|
||||
{
|
||||
val dependencyDescriptor = new DefaultDependencyDescriptor(moduleID, toID(dependency), false, dependency.isChanging, dependency.isTransitive)
|
||||
val dependencyDescriptor = new DefaultDependencyDescriptor(moduleID, toID(dependency), dependency.isForce, dependency.isChanging, dependency.isTransitive)
|
||||
dependency.configurations match
|
||||
{
|
||||
case None => // The configuration for this dependency was not explicitly specified, so use the default
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import scala.xml.NodeSeq
|
|||
import org.apache.ivy.plugins.resolver.{DependencyResolver, IBiblioResolver}
|
||||
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, exclusions: Seq[ExclusionRule] = Nil, extraAttributes: Map[String,String] = Map.empty, crossVersion: CrossVersion = CrossVersion.Disabled)
|
||||
final case class ModuleID(organization: String, name: String, revision: String, configurations: Option[String] = None, isChanging: Boolean = false, isTransitive: Boolean = true, isForce: Boolean = false, explicitArtifacts: Seq[Artifact] = Nil, exclusions: Seq[ExclusionRule] = Nil, extraAttributes: Map[String,String] = Map.empty, crossVersion: CrossVersion = CrossVersion.Disabled)
|
||||
{
|
||||
override def toString =
|
||||
organization + ":" + name + ":" + revision +
|
||||
|
|
@ -28,6 +28,7 @@ final case class ModuleID(organization: String, name: String, revision: String,
|
|||
def notTransitive() = intransitive()
|
||||
def intransitive() = copy(isTransitive = false)
|
||||
def changing() = copy(isChanging = true)
|
||||
def force() = copy(isForce = true)
|
||||
def from(url: String) = artifacts(Artifact(name, new URL(url)))
|
||||
def classifier(c: String) = artifacts(Artifact(name, c))
|
||||
def artifacts(newArtifacts: Artifact*) = copy(explicitArtifacts = newArtifacts ++ this.explicitArtifacts)
|
||||
|
|
|
|||
|
|
@ -92,9 +92,9 @@ object CacheIvy
|
|||
private[this] val crossToInt = (c: CrossVersion) => c match { case Disabled => 0; case b: Binary => BinaryValue; case f: Full => FullValue }
|
||||
|
||||
implicit def moduleIDFormat(implicit sf: Format[String], af: Format[Artifact], bf: Format[Boolean], ef: Format[ExclusionRule]): Format[ModuleID] =
|
||||
wrap[ModuleID, ((String,String,String,Option[String]),(Boolean,Boolean,Seq[Artifact],Seq[ExclusionRule],Map[String,String],CrossVersion))](
|
||||
m => ((m.organization,m.name,m.revision,m.configurations), (m.isChanging, m.isTransitive, m.explicitArtifacts, m.exclusions, m.extraAttributes, m.crossVersion)),
|
||||
{ case ((o,n,r,cs),(ch,t,as,excl,x,cv)) => ModuleID(o,n,r,cs,ch,t,as,excl,x,cv) }
|
||||
wrap[ModuleID, ((String,String,String,Option[String]),(Boolean,Boolean,Boolean,Seq[Artifact],Seq[ExclusionRule],Map[String,String],CrossVersion))](
|
||||
m => ((m.organization,m.name,m.revision,m.configurations), (m.isChanging, m.isTransitive, m.isForce, m.explicitArtifacts, m.exclusions, m.extraAttributes, m.crossVersion)),
|
||||
{ case ((o,n,r,cs),(ch,t,f,as,excl,x,cv)) => ModuleID(o,n,r,cs,ch,t,f,as,excl,x,cv) }
|
||||
)
|
||||
|
||||
implicit def configurationFormat(implicit sf: Format[String]): Format[Configuration] =
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
import sbt._
|
||||
import Keys._
|
||||
|
||||
object TestProject extends Build
|
||||
{
|
||||
lazy val root = Project("root", file(".")) settings(
|
||||
ivyPaths <<= (baseDirectory, target)( (dir, t) => new IvyPaths(dir, Some(t / "ivy-cache"))),
|
||||
libraryDependencies <++= baseDirectory (libraryDeps),
|
||||
TaskKey[Unit]("check-forced") <<= check("1.2.14"),
|
||||
TaskKey[Unit]("check-depend") <<= check("1.2.13")
|
||||
)
|
||||
|
||||
def libraryDeps(base: File) = {
|
||||
val slf4j = Seq("org.slf4j" % "slf4j-log4j12" % "1.1.0") // Uses log4j 1.2.13
|
||||
if ((base / "force").exists) slf4j :+ ("log4j" % "log4j" % "1.2.14" force()) else slf4j
|
||||
}
|
||||
|
||||
def check(ver: String) =
|
||||
(dependencyClasspath in Compile) map { jars =>
|
||||
val log4j = jars map (_.data) collect {
|
||||
case f if f.getName contains "log4j-" => f.getName
|
||||
}
|
||||
if (log4j.size != 1 || !log4j.head.contains(ver))
|
||||
error("Did not download the correct jar.")
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
$ touch force
|
||||
|
||||
> reload
|
||||
|
||||
> check-forced
|
||||
-> check-depend
|
||||
|
||||
$ delete force
|
||||
> reload
|
||||
|
||||
-> check-forced
|
||||
> check-depend
|
||||
Loading…
Reference in New Issue