Skip to content

Commit bb81280

Browse files
committed
Include artifact classifier in name
1 parent ddf240f commit bb81280

File tree

2 files changed

+27
-14
lines changed

2 files changed

+27
-14
lines changed

src/main/scala/software/purpledragon/sbt/lock/DependencyUtils.scala

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import java.time.Instant
2121
import sbt._
2222
import software.purpledragon.sbt.lock.model.{DependencyLockFile, DependencyRef, ResolvedArtifact, ResolvedDependency}
2323

24-
import scala.collection.{immutable, mutable, SortedSet}
24+
import scala.collection.{SortedSet, immutable, mutable}
2525

2626
object DependencyUtils {
2727
def resolve(updateReport: UpdateReport, configs: Seq[ConfigRef]): DependencyLockFile = {
@@ -64,17 +64,8 @@ object DependencyUtils {
6464
module: ModuleReport,
6565
checksumCache: mutable.Map[File, String]): ResolvedDependency = {
6666

67-
val artifacts: immutable.Seq[ResolvedArtifact] = module.artifacts map {
68-
case (artifact, file) =>
69-
val hash = checksumCache.getOrElseUpdate(file, hashFile(file))
70-
71-
val qualifier = artifact.`type` match {
72-
case "jar" | "bundle" => ""
73-
case q => s"-$q"
74-
}
75-
76-
ResolvedArtifact(s"${artifact.name}$qualifier.${artifact.extension}", hash)
77-
}
67+
val artifacts =
68+
module.artifacts.map(ResolvedArtifact.apply(_, checksumCache))
7869

7970
ResolvedDependency(
8071
module.module.organization,
@@ -83,6 +74,4 @@ object DependencyUtils {
8374
artifacts.to[SortedSet],
8475
SortedSet.empty)
8576
}
86-
87-
private def hashFile(file: File): String = s"sha1:${Hash.toHex(Hash(file))}"
8877
}

src/main/scala/software/purpledragon/sbt/lock/model/ResolvedArtifact.scala

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,34 @@
1616

1717
package software.purpledragon.sbt.lock.model
1818

19+
import java.io.File
20+
21+
import sbt.{File, Hash}
22+
import sbt.librarymanagement.Artifact
23+
import software.purpledragon.sbt.lock.DependencyUtils.hashFile
24+
25+
import scala.collection.mutable
1926
import scala.math.Ordered.orderingToOrdered
2027

2128
final case class ResolvedArtifact(name: String, hash: String) extends Ordered[ResolvedArtifact] {
2229
override def compare(that: ResolvedArtifact): Int = {
2330
(name, hash) compare (that.name, that.hash)
2431
}
2532
}
33+
34+
object ResolvedArtifact {
35+
def apply(art: (Artifact, File), checksumCache: mutable.Map[File, String]): ResolvedArtifact = {
36+
val (artifact, file) = art
37+
val hash = checksumCache.getOrElseUpdate(file, hashFile(file))
38+
39+
val classifier = artifact.classifier.map(c => s"-$c").getOrElse("")
40+
val qualifier = artifact.`type` match {
41+
case "jar" | "bundle" => ""
42+
case q => s"-$q"
43+
}
44+
45+
ResolvedArtifact(s"${artifact.name}$classifier$qualifier.${artifact.extension}", hash)
46+
}
47+
48+
private def hashFile(file: File): String = s"sha1:${Hash.toHex(Hash(file))}"
49+
}

0 commit comments

Comments
 (0)