Rename MavenArtifact to Attributes

This commit is contained in:
Alexandre Archambault 2015-06-25 00:18:54 +01:00
parent d2885c59b4
commit d30be245dc
9 changed files with 24 additions and 26 deletions

View File

@ -104,7 +104,7 @@ case class Coursier(scope: List[String],
if (version == dep.version) ""
else s" ($version for ${dep.version})"
s"${dep.module.organization}:${dep.module.name}:${dep.artifact.`type`}:${Some(dep.artifact.classifier).filter(_.nonEmpty).map(_+":").mkString}$version$extra"
s"${dep.module.organization}:${dep.module.name}:${dep.attributes.`type`}:${Some(dep.attributes.classifier).filter(_.nonEmpty).map(_+":").mkString}$version$extra"
}
val trDeps = res.minDependencies.toList.sortBy(repr)

View File

@ -21,14 +21,14 @@ case class ArtifactDownloader(root: String, cache: File, logger: Option[Artifact
def artifact(module: Module,
version: String,
artifact: Dependency.MavenArtifact,
attributes: Attributes,
cachePolicy: CachePolicy): EitherT[Task, String, File] = {
val relPath =
module.organization.split('.').toSeq ++ Seq(
module.name,
version,
s"${module.name}-$version${Some(artifact.classifier).filter(_.nonEmpty).map("-"+_).mkString}.${artifact.`type`}"
s"${module.name}-$version${Some(attributes.classifier).filter(_.nonEmpty).map("-"+_).mkString}.${attributes.`type`}"
)
val file = (cache /: relPath)(new File(_, _))
@ -96,7 +96,7 @@ case class ArtifactDownloader(root: String, cache: File, logger: Option[Artifact
cachePolicy: CachePolicy = CachePolicy.Default): Task[Seq[String \/ File]] = {
// Important: using version from project, as the one from dependency can be an interval
artifact(dependency.module, project.version, dependency.artifact, cachePolicy = cachePolicy).run.map(Seq(_))
artifact(dependency.module, project.version, dependency.attributes, cachePolicy = cachePolicy).run.map(Seq(_))
}
}

View File

@ -32,16 +32,14 @@ sealed abstract class Scope(val name: String)
case class Dependency(module: Module,
version: String,
scope: Scope,
artifact: Dependency.MavenArtifact,
attributes: Attributes,
exclusions: Set[(String, String)],
optional: Boolean) {
def moduleVersion = (module, version)
}
object Dependency {
case class MavenArtifact(`type`: String,
classifier: String)
}
case class Attributes(`type`: String,
classifier: String)
case class Project(module: Module,
version: String,

View File

@ -70,7 +70,7 @@ object Resolution {
type DepMgmtKey = (String, String, String)
def dependencyManagementKey(dep: Dependency): DepMgmtKey =
(dep.module.organization, dep.module.name, dep.artifact.`type`)
(dep.module.organization, dep.module.name, dep.attributes.`type`)
def dependencyManagementAdd(m: Map[DepMgmtKey, Dependency], dep: Dependency): Map[DepMgmtKey, Dependency] = {
val key = dependencyManagementKey(dep)
if (m.contains(key)) m else m + (key -> dep)
@ -119,9 +119,9 @@ object Resolution {
name = substituteProps(dep.module.name)
),
version = substituteProps(dep.version),
artifact = dep.artifact.copy(
`type` = substituteProps(dep.artifact.`type`),
classifier = substituteProps(dep.artifact.classifier)
attributes = dep.attributes.copy(
`type` = substituteProps(dep.attributes.`type`),
classifier = substituteProps(dep.attributes.classifier)
),
scope = Parse.scope(substituteProps(dep.scope.name)),
exclusions = dep.exclusions

View File

@ -85,7 +85,7 @@ object Xml {
mod,
version0,
scopeOpt getOrElse defaultScope,
Dependency.MavenArtifact(typeOpt getOrElse defaultType, classifierOpt getOrElse defaultClassifier),
Attributes(typeOpt getOrElse defaultType, classifierOpt getOrElse defaultClassifier),
exclusions.map(mod => (mod.organization, mod.name)).toSet,
optional
)

View File

@ -11,17 +11,17 @@ package object coursier {
def apply(module: Module,
version: String,
scope: Scope = Scope.Other(""), // Substituted by Resolver with its own default scope (compile)
artifact: MavenArtifact = MavenArtifact(),
attributes: Attributes = Attributes(),
exclusions: Set[(String, String)] = Set.empty,
optional: Boolean = false): Dependency =
core.Dependency(module, version, scope, artifact, exclusions, optional)
core.Dependency(module, version, scope, attributes, exclusions, optional)
}
type MavenArtifact = core.Dependency.MavenArtifact
object MavenArtifact {
def apply(`type`: String = "jar",
classifier: String = ""): MavenArtifact =
core.Dependency.MavenArtifact(`type`, classifier)
}
type Attributes = core.Attributes
object Attributes {
def apply(`type`: String = "jar",
classifier: String = ""): Attributes =
core.Attributes(`type`, classifier)
}
type Project = core.Project

View File

@ -13,7 +13,7 @@ object CentralTests extends TestSuite {
)
def repr(dep: Dependency) =
s"${dep.module.organization}:${dep.module.name}:${dep.artifact.`type`}:${Some(dep.artifact.classifier).filter(_.nonEmpty).map(_+":").mkString}${dep.version}"
s"${dep.module.organization}:${dep.module.name}:${dep.attributes.`type`}:${Some(dep.attributes.classifier).filter(_.nonEmpty).map(_+":").mkString}${dep.version}"
def resolutionCheck(module: Module, version: String) =
async {

View File

@ -21,7 +21,7 @@ object PomParsingTests extends TestSuite {
</dependency>
"""
val expected = \/-(Dependency(Module("comp", "lib"), "2.1", artifact = Dependency.MavenArtifact(classifier = "extra")))
val expected = \/-(Dependency(Module("comp", "lib"), "2.1", attributes = Attributes(classifier = "extra")))
val result = Xml.dependency(xmlParse(depNode).right.get)

View File

@ -230,8 +230,8 @@ object App {
<.td(finalVersionOpt.fold(dep.version)(finalVersion => s"$finalVersion (for ${dep.version})")),
<.td(Seq[Seq[TagMod]](
if (dep.scope == Scope.Compile) Seq() else Seq(infoLabel(dep.scope.name)),
if (dep.artifact.`type`.isEmpty || dep.artifact.`type` == "jar") Seq() else Seq(infoLabel(dep.artifact.`type`)),
if (dep.artifact.classifier.isEmpty) Seq() else Seq(infoLabel(dep.artifact.classifier)),
if (dep.attributes.`type`.isEmpty || dep.attributes.`type` == "jar") Seq() else Seq(infoLabel(dep.attributes.`type`)),
if (dep.attributes.classifier.isEmpty) Seq() else Seq(infoLabel(dep.attributes.classifier)),
Some(dep.exclusions).filter(_.nonEmpty).map(excls => infoPopOver("Exclusions", excls.toList.sorted.map{case (org, name) => s"$org:$name"}.mkString("; "))).toSeq,
if (dep.optional) Seq(infoLabel("optional")) else Seq(),
res.errors.get(dep.moduleVersion).map(errs => errorPopOver("Error", errs.mkString("; "))).toSeq