mirror of https://github.com/sbt/sbt.git
added hashing function
This commit is contained in:
parent
0499b58819
commit
572f87314f
|
|
@ -261,7 +261,7 @@ lazy val lmIvy = (project in file("ivy"))
|
|||
)
|
||||
|
||||
lazy val lmCoursier = (project in file("coursier"))
|
||||
.enablePlugins(ContrabandPlugin)
|
||||
.enablePlugins(ContrabandPlugin, JsonCodecPlugin)
|
||||
.dependsOn(lmIvy)
|
||||
.settings(
|
||||
commonSettings,
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package sbt.librarymanagement.coursier
|
|||
import java.io.{ File, OutputStreamWriter }
|
||||
import java.util.concurrent.Executors
|
||||
|
||||
import scala.util.{ Success, Failure }
|
||||
import scala.concurrent.ExecutionContext
|
||||
|
||||
import coursier.{ Artifact, Resolution, _ }
|
||||
|
|
@ -11,6 +12,9 @@ import sbt.librarymanagement.Configurations.{ CompilerPlugin, Component, ScalaTo
|
|||
import sbt.librarymanagement._
|
||||
import sbt.util.Logger
|
||||
|
||||
import sjsonnew.JsonFormat
|
||||
import sjsonnew.support.murmurhash.Hasher
|
||||
|
||||
case class CoursierModuleDescriptor(
|
||||
directDependencies: Vector[ModuleID],
|
||||
scalaModuleInfo: Option[ScalaModuleInfo],
|
||||
|
|
@ -37,6 +41,52 @@ private[sbt] class CoursierDependencyResolution(coursierConfiguration: CoursierC
|
|||
} else _resolvers
|
||||
}
|
||||
|
||||
private[sbt] object AltLibraryManagementCodec extends CoursierLibraryManagementCodec {
|
||||
type CoursierHL = (
|
||||
Vector[Resolver],
|
||||
Vector[Resolver],
|
||||
Boolean,
|
||||
Int,
|
||||
Int
|
||||
)
|
||||
|
||||
def coursierToHL(c: CoursierConfiguration): CoursierHL =
|
||||
(
|
||||
c.resolvers,
|
||||
c.otherResolvers,
|
||||
c.reorderResolvers,
|
||||
c.parallelDownloads,
|
||||
c.maxIterations
|
||||
)
|
||||
// Redefine to use a subset of properties, that are serialisable
|
||||
override implicit lazy val CoursierConfigurationFormat: JsonFormat[CoursierConfiguration] = {
|
||||
def hlToCoursier(c: CoursierHL): CoursierConfiguration = {
|
||||
val (
|
||||
resolvers,
|
||||
otherResolvers,
|
||||
reorderResolvers,
|
||||
parallelDownloads,
|
||||
maxIterations
|
||||
) = c
|
||||
CoursierConfiguration()
|
||||
.withResolvers(resolvers)
|
||||
.withOtherResolvers(otherResolvers)
|
||||
.withReorderResolvers(reorderResolvers)
|
||||
.withParallelDownloads(parallelDownloads)
|
||||
.withMaxIterations(maxIterations)
|
||||
}
|
||||
projectFormat[CoursierConfiguration, CoursierHL](coursierToHL, hlToCoursier)
|
||||
}
|
||||
}
|
||||
|
||||
def extraInputHash: Long = {
|
||||
import AltLibraryManagementCodec._
|
||||
Hasher.hash(coursierConfiguration) match {
|
||||
case Success(keyHash) => keyHash.toLong
|
||||
case Failure(_) => 0L
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a ModuleDescriptor that describes a subproject with dependencies.
|
||||
*
|
||||
|
|
@ -49,7 +99,7 @@ private[sbt] class CoursierDependencyResolution(coursierConfiguration: CoursierC
|
|||
moduleSetting.dependencies,
|
||||
moduleSetting.scalaModuleInfo,
|
||||
CoursierModuleSettings(),
|
||||
1L // FIXME: use correct value
|
||||
extraInputHash
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
package sbt.librarymanagement
|
||||
package coursier
|
||||
|
||||
trait CoursierLibraryManagementCodec
|
||||
extends sjsonnew.BasicJsonProtocol
|
||||
with LibraryManagementCodec
|
||||
// with sbt.internal.librarymanagement.formats.GlobalLockFormat
|
||||
with sbt.internal.librarymanagement.formats.LoggerFormat
|
||||
with sbt.librarymanagement.ResolverFormats
|
||||
with CoursierConfigurationFormats
|
||||
|
||||
object CoursierLibraryManagementCodec extends CoursierLibraryManagementCodec
|
||||
Loading…
Reference in New Issue