mirror of https://github.com/sbt/sbt.git
Support for classifiers to the extent that Ivy supports them:
- can publish artifacts with classifiers - can retrieve artifacts with classifiers, but classifier does not appear in generated pom git-svn-id: https://simple-build-tool.googlecode.com/svn/trunk@879 d89573ee-9141-11dd-94d4-bdf5e562f29c
This commit is contained in:
parent
8420606a8c
commit
e58cd74987
|
|
@ -268,13 +268,16 @@ object ManageDependencies
|
|||
ivy.pushContext()
|
||||
try
|
||||
{
|
||||
moduleDescriptor.right.flatMap(checkModule).right.flatMap { mdAndConf =>
|
||||
doWithIvy(ivy, mdAndConf._1, mdAndConf._2)
|
||||
moduleDescriptor.right.flatMap(checkModule).right.flatMap { case (md, conf) =>
|
||||
addExtraNamespaces(toDefaultModuleDescriptor(md))
|
||||
doWithIvy(ivy, md, conf)
|
||||
}
|
||||
}
|
||||
finally { ivy.popContext() }
|
||||
}
|
||||
}
|
||||
private def addExtraNamespaces(md: DefaultModuleDescriptor): Unit =
|
||||
md.getExtraAttributesNamespaces.asInstanceOf[java.util.Map[String,String]].put("m", "m")
|
||||
/** Checks the immediate dependencies of module for dependencies on scala jars and verifies that the version on the
|
||||
* dependencies matches scalaVersion. */
|
||||
private def checkDependencies(module: ModuleDescriptor, scalaVersion: String, configurations: Iterable[Configuration]): Option[String] =
|
||||
|
|
@ -488,8 +491,9 @@ object ManageDependencies
|
|||
}
|
||||
for(artifact <- dependency.explicitArtifacts)
|
||||
{
|
||||
import artifact.{name, `type`, extension, url}
|
||||
val ivyArtifact = new DefaultDependencyArtifactDescriptor(dependencyDescriptor, name, `type`, extension, url.getOrElse(null), null)
|
||||
import artifact.{name, classifier, `type`, extension, url}
|
||||
val extraMap = extra(artifact)
|
||||
val ivyArtifact = new DefaultDependencyArtifactDescriptor(dependencyDescriptor, name, `type`, extension, url.getOrElse(null), extraMap)
|
||||
for(conf <- dependencyDescriptor.getModuleConfigurations)
|
||||
dependencyDescriptor.addDependencyArtifact(conf, ivyArtifact)
|
||||
}
|
||||
|
|
@ -513,6 +517,8 @@ object ManageDependencies
|
|||
configurationStrings.foreach(configuration => moduleID.addArtifact(configuration, ivyArtifact))
|
||||
}
|
||||
}
|
||||
private def extra(artifact: Artifact) =
|
||||
artifact.classifier.map(c => wrap.Wrappers.javaMap("m:classifier" -> c)).getOrElse(null)
|
||||
private def toURL(file: File) = file.toURI.toURL
|
||||
/** Adds the ivy.xml main artifact. */
|
||||
private def addMainArtifact(moduleID: DefaultModuleDescriptor)
|
||||
|
|
@ -551,7 +557,7 @@ object ManageDependencies
|
|||
}
|
||||
private def toIvyArtifact(moduleID: ModuleDescriptor, a: Artifact, configurations: Iterable[String]): MDArtifact =
|
||||
{
|
||||
val artifact = new MDArtifact(moduleID, a.name, a.`type`, a.extension)
|
||||
val artifact = new MDArtifact(moduleID, a.name, a.`type`, a.extension, null, extra(a))
|
||||
configurations.foreach(artifact.addConfiguration)
|
||||
artifact
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ final case class ModuleID(organization: String, name: String, revision: String,
|
|||
def intransitive() = ModuleID(organization, name, revision, configurations, isChanging, false, explicitArtifacts)
|
||||
def changing() = ModuleID(organization, name, revision, configurations, true, isTransitive, explicitArtifacts)
|
||||
def from(url: String) = artifacts(Artifact(name, new URL(url)))
|
||||
def classifier(c: String) = artifacts(Artifact(name, c))
|
||||
def artifacts(newArtifacts: Artifact*) = ModuleID(organization, name, revision, configurations, isChanging, isTransitive, newArtifacts ++ explicitArtifacts)
|
||||
}
|
||||
object ModuleID
|
||||
|
|
@ -319,12 +320,13 @@ final case class Configuration(name: String, description: String, isPublic: Bool
|
|||
override def toString = name
|
||||
}
|
||||
|
||||
final case class Artifact(name: String, `type`: String, extension: String, configurations: Iterable[Configuration], url: Option[URL]) extends NotNull
|
||||
final case class Artifact(name: String, `type`: String, extension: String, classifier: Option[String], configurations: Iterable[Configuration], url: Option[URL]) extends NotNull
|
||||
object Artifact
|
||||
{
|
||||
def apply(name: String): Artifact = Artifact(name, defaultType, defaultExtension, Nil, None)
|
||||
def apply(name: String, `type`: String, extension: String): Artifact = Artifact(name, `type`, extension, Nil, None)
|
||||
def apply(name: String, url: URL): Artifact =Artifact(name, extract(url, defaultType), extract(url, defaultExtension), Nil, Some(url))
|
||||
def apply(name: String): Artifact = Artifact(name, defaultType, defaultExtension, None, Nil, None)
|
||||
def apply(name: String, classifier: String): Artifact = Artifact(name, defaultType, defaultExtension, Some(classifier), Nil, None)
|
||||
def apply(name: String, `type`: String, extension: String): Artifact = Artifact(name, `type`, extension, None, Nil, None)
|
||||
def apply(name: String, url: URL): Artifact =Artifact(name, extract(url, defaultType), extract(url, defaultExtension), None, Nil, Some(url))
|
||||
val defaultExtension = "jar"
|
||||
val defaultType = "jar"
|
||||
private[this] def extract(url: URL, default: String) =
|
||||
|
|
|
|||
|
|
@ -9,6 +9,14 @@ import java.util.{Map => JMap, Set => JSet}
|
|||
|
||||
private[sbt] object Wrappers
|
||||
{
|
||||
def javaMap[K,V](pairs: (K,V)*) =
|
||||
{
|
||||
val basic = basicMap[K,V]
|
||||
for( (k,v) <- pairs)
|
||||
basic(k) = v
|
||||
basic.underlying
|
||||
}
|
||||
def basicMap[K,V] = new MutableMapWrapper(new java.util.HashMap[K,V])
|
||||
def identityMap[K,V] = new MutableMapWrapper(new java.util.IdentityHashMap[K,V])
|
||||
def weakMap[K,V] = new MutableMapWrapper(new java.util.WeakHashMap[K,V])
|
||||
def toList[K,V](s: java.util.Map[K,V]): List[(K,V)] = toList(s.entrySet).map(e => (e.getKey, e.getValue))
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
project.name=Test Classifier
|
||||
project.version=1.0
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
import sbt._
|
||||
|
||||
class Test(info: ProjectInfo) extends DefaultProject(info)
|
||||
{
|
||||
val testng = "org.testng" % "testng" % "5.7" classifier "jdk15"
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
> update
|
||||
[success]
|
||||
Loading…
Reference in New Issue