diff --git a/cli/src/main/scala/coursier/cli/Coursier.scala b/cli/src/main/scala/coursier/cli/Coursier.scala index 23f7cb2de..a131660e2 100644 --- a/cli/src/main/scala/coursier/cli/Coursier.scala +++ b/cli/src/main/scala/coursier/cli/Coursier.scala @@ -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) diff --git a/core-jvm/src/main/scala/coursier/core/Remote.scala b/core-jvm/src/main/scala/coursier/core/Remote.scala index 414a8a00f..27f0427e1 100644 --- a/core-jvm/src/main/scala/coursier/core/Remote.scala +++ b/core-jvm/src/main/scala/coursier/core/Remote.scala @@ -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(_)) } } diff --git a/core/src/main/scala/coursier/core/Definitions.scala b/core/src/main/scala/coursier/core/Definitions.scala index b0836f7f7..6a331e291 100644 --- a/core/src/main/scala/coursier/core/Definitions.scala +++ b/core/src/main/scala/coursier/core/Definitions.scala @@ -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, diff --git a/core/src/main/scala/coursier/core/Resolution.scala b/core/src/main/scala/coursier/core/Resolution.scala index 2b4805daf..8596bb480 100644 --- a/core/src/main/scala/coursier/core/Resolution.scala +++ b/core/src/main/scala/coursier/core/Resolution.scala @@ -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 diff --git a/core/src/main/scala/coursier/core/Xml.scala b/core/src/main/scala/coursier/core/Xml.scala index 2c92a03bc..caa2a3156 100644 --- a/core/src/main/scala/coursier/core/Xml.scala +++ b/core/src/main/scala/coursier/core/Xml.scala @@ -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 ) diff --git a/core/src/main/scala/coursier/package.scala b/core/src/main/scala/coursier/package.scala index 476b730ee..87402dff0 100644 --- a/core/src/main/scala/coursier/package.scala +++ b/core/src/main/scala/coursier/package.scala @@ -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 diff --git a/core/src/test/scala/coursier/test/CentralTests.scala b/core/src/test/scala/coursier/test/CentralTests.scala index 693769100..3b36d9694 100644 --- a/core/src/test/scala/coursier/test/CentralTests.scala +++ b/core/src/test/scala/coursier/test/CentralTests.scala @@ -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 { diff --git a/core/src/test/scala/coursier/test/PomParsingTests.scala b/core/src/test/scala/coursier/test/PomParsingTests.scala index 8b3d9fbf9..3135c4905 100644 --- a/core/src/test/scala/coursier/test/PomParsingTests.scala +++ b/core/src/test/scala/coursier/test/PomParsingTests.scala @@ -21,7 +21,7 @@ object PomParsingTests extends TestSuite { """ - 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) diff --git a/web/src/main/scala/coursier/web/Backend.scala b/web/src/main/scala/coursier/web/Backend.scala index 317ec5efe..3cad52b95 100644 --- a/web/src/main/scala/coursier/web/Backend.scala +++ b/web/src/main/scala/coursier/web/Backend.scala @@ -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