Skip to content

Commit fd9a11f

Browse files
committed
Include artifact classifier in name
1 parent f9cfdad commit fd9a11f

File tree

2 files changed

+27
-15
lines changed

2 files changed

+27
-15
lines changed

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

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@
1616

1717
package software.purpledragon.sbt.lock
1818

19-
import java.time.Instant
20-
2119
import sbt._
2220
import software.purpledragon.sbt.lock.model.{DependencyLockFile, DependencyRef, ResolvedArtifact, ResolvedDependency}
2321

24-
import scala.collection.{immutable, mutable, SortedSet}
22+
import java.time.Instant
23+
import scala.collection.{SortedSet, immutable, mutable}
2524

2625
object DependencyUtils {
2726
def resolve(updateReport: UpdateReport, configs: Seq[ConfigRef]): DependencyLockFile = {
@@ -64,16 +63,7 @@ object DependencyUtils {
6463
module: ModuleReport,
6564
checksumCache: mutable.Map[File, String]): ResolvedDependency = {
6665

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

7868
ResolvedDependency(
7969
module.module.organization,
@@ -82,6 +72,4 @@ object DependencyUtils {
8272
artifacts.to[SortedSet],
8373
SortedSet.empty)
8474
}
85-
86-
private def hashFile(file: File): String = s"sha1:${Hash.toHex(Hash(file))}"
8775
}

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)