mirror of https://github.com/sbt/sbt.git
Move `managedChecksums` to InlineIvyConfiguration
`UpdateOptions` is only meant for user-provided options. Since this option should not be exposed to users, it's moved to inline ivy configuration, whose parameters require information about the build and is usually defined project-wide instead of `Global`-wide.
This commit is contained in:
parent
e3a52c3e1f
commit
27bf130853
|
|
@ -742,6 +742,7 @@
|
|||
{ "name": "otherResolvers", "type": "sbt.librarymanagement.Resolver*" },
|
||||
{ "name": "moduleConfigurations", "type": "sbt.librarymanagement.ModuleConfiguration*" },
|
||||
{ "name": "checksums", "type": "String*" },
|
||||
{ "name": "managedChecksums", "type": "Boolean" },
|
||||
{ "name": "resolutionCacheDir", "type": "java.io.File?" }
|
||||
],
|
||||
"extra": [
|
||||
|
|
@ -752,12 +753,13 @@
|
|||
" moduleConfigurations: Vector[sbt.librarymanagement.ModuleConfiguration],",
|
||||
" lock: Option[xsbti.GlobalLock],",
|
||||
" checksums: Vector[String],",
|
||||
" managedChecksums: Boolean,",
|
||||
" resolutionCacheDir: Option[java.io.File],",
|
||||
" updateOptions: sbt.librarymanagement.UpdateOptions,",
|
||||
" log: xsbti.Logger",
|
||||
") =",
|
||||
" this(lock, paths.baseDirectory, log, updateOptions, paths, resolvers, otherResolvers,",
|
||||
" moduleConfigurations, checksums, resolutionCacheDir)"
|
||||
" moduleConfigurations, checksums, managedChecksums, resolutionCacheDir)"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ private[sbt] object ConvertResolver {
|
|||
def apply(r: Resolver, settings: IvySettings, log: Logger): DependencyResolver =
|
||||
apply(r, settings, UpdateOptions(), log)
|
||||
|
||||
private[librarymanagement] val ManagedChecksums = "managedChecksums"
|
||||
private[librarymanagement] val ManagedChecksums = "sbt.managedChecksums"
|
||||
|
||||
/** Converts the given sbt resolver into an Ivy resolver. */
|
||||
def apply(
|
||||
|
|
@ -149,11 +149,8 @@ private[sbt] object ConvertResolver {
|
|||
settings: IvySettings,
|
||||
updateOptions: UpdateOptions,
|
||||
log: Logger
|
||||
): DependencyResolver = {
|
||||
// Pass in to the resolver converter the update options via ivy settings
|
||||
settings.setVariable(ManagedChecksums, updateOptions.managedChecksums.toString)
|
||||
): DependencyResolver =
|
||||
(updateOptions.resolverConverter orElse defaultConvert)((r, settings, log))
|
||||
}
|
||||
|
||||
/** The default implementation of converter. */
|
||||
lazy val defaultConvert: ResolverConverter = {
|
||||
|
|
|
|||
|
|
@ -87,6 +87,7 @@ final class IvySbt(val configuration: IvyConfiguration) { self =>
|
|||
IvySbt.loadURI(is, e.uri)
|
||||
case i: InlineIvyConfiguration =>
|
||||
is.setVariable("ivy.checksums", i.checksums mkString ",")
|
||||
is.setVariable(ConvertResolver.ManagedChecksums, i.managedChecksums.toString)
|
||||
i.paths.ivyHome foreach is.setDefaultIvyUserDir
|
||||
val log = configuration.log
|
||||
IvySbt.configureCache(is, i.resolutionCacheDir)
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ class IvyCache(val ivyHome: Option[File]) {
|
|||
Vector.empty,
|
||||
lock,
|
||||
IvySbt.DefaultChecksums,
|
||||
false,
|
||||
None,
|
||||
UpdateOptions(),
|
||||
log
|
||||
|
|
|
|||
|
|
@ -26,19 +26,17 @@ trait UpdateOptionsFormat { self: BasicJsonProtocol with ModuleIDFormats with Re
|
|||
uo.latestSnapshots,
|
||||
uo.consolidatedResolution,
|
||||
uo.cachedResolution,
|
||||
uo.managedChecksums,
|
||||
uo.moduleResolvers
|
||||
),
|
||||
(xs: (String, Boolean, Boolean, Boolean, Boolean, Boolean, Map[ModuleID, Resolver])) =>
|
||||
(xs: (String, Boolean, Boolean, Boolean, Boolean, Map[ModuleID, Resolver])) =>
|
||||
new UpdateOptions(
|
||||
levels(xs._1),
|
||||
xs._2,
|
||||
xs._3,
|
||||
xs._4,
|
||||
xs._5,
|
||||
xs._6,
|
||||
PartialFunction.empty,
|
||||
xs._7
|
||||
xs._6
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -9,9 +9,6 @@ import sbt.util.Logger
|
|||
* While UpdateConfiguration is passed into update at runtime,
|
||||
* UpdateOption is intended to be used while setting up the Ivy object.
|
||||
*
|
||||
* @param managedChecksums Managed checksums tells ivy whether it should only download the
|
||||
* checksum files and let the caller handle the verification.
|
||||
*
|
||||
* See also UpdateConfiguration in IvyActions.scala.
|
||||
*/
|
||||
final class UpdateOptions private[sbt] (
|
||||
|
|
@ -25,8 +22,6 @@ final class UpdateOptions private[sbt] (
|
|||
val consolidatedResolution: Boolean,
|
||||
// If set to true, use cached resolution.
|
||||
val cachedResolution: Boolean,
|
||||
// If set to true, use managed checksums.
|
||||
val managedChecksums: Boolean,
|
||||
// Extension point for an alternative resolver converter.
|
||||
val resolverConverter: UpdateOptions.ResolverConverter,
|
||||
// Map the unique resolver to be checked for the module ID
|
||||
|
|
@ -59,16 +54,12 @@ final class UpdateOptions private[sbt] (
|
|||
def withModuleResolvers(moduleResolvers: Map[ModuleID, Resolver]): UpdateOptions =
|
||||
copy(moduleResolvers = moduleResolvers)
|
||||
|
||||
def withManagedChecksums(managedChecksums: Boolean): UpdateOptions =
|
||||
copy(managedChecksums = managedChecksums)
|
||||
|
||||
private[sbt] def copy(
|
||||
circularDependencyLevel: CircularDependencyLevel = this.circularDependencyLevel,
|
||||
interProjectFirst: Boolean = this.interProjectFirst,
|
||||
latestSnapshots: Boolean = this.latestSnapshots,
|
||||
consolidatedResolution: Boolean = this.consolidatedResolution,
|
||||
cachedResolution: Boolean = this.cachedResolution,
|
||||
managedChecksums: Boolean = this.managedChecksums,
|
||||
resolverConverter: UpdateOptions.ResolverConverter = this.resolverConverter,
|
||||
moduleResolvers: Map[ModuleID, Resolver] = this.moduleResolvers
|
||||
): UpdateOptions =
|
||||
|
|
@ -78,7 +69,6 @@ final class UpdateOptions private[sbt] (
|
|||
latestSnapshots,
|
||||
consolidatedResolution,
|
||||
cachedResolution,
|
||||
managedChecksums,
|
||||
resolverConverter,
|
||||
moduleResolvers
|
||||
)
|
||||
|
|
@ -89,7 +79,6 @@ final class UpdateOptions private[sbt] (
|
|||
this.interProjectFirst == o.interProjectFirst &&
|
||||
this.latestSnapshots == o.latestSnapshots &&
|
||||
this.cachedResolution == o.cachedResolution &&
|
||||
this.managedChecksums == o.managedChecksums &&
|
||||
this.resolverConverter == o.resolverConverter &&
|
||||
this.moduleResolvers == o.moduleResolvers
|
||||
case _ => false
|
||||
|
|
@ -101,7 +90,6 @@ final class UpdateOptions private[sbt] (
|
|||
hash = hash * 31 + this.interProjectFirst.##
|
||||
hash = hash * 31 + this.latestSnapshots.##
|
||||
hash = hash * 31 + this.cachedResolution.##
|
||||
hash = hash * 31 + this.managedChecksums.##
|
||||
hash = hash * 31 + this.resolverConverter.##
|
||||
hash = hash * 31 + this.moduleResolvers.##
|
||||
hash
|
||||
|
|
@ -118,7 +106,6 @@ object UpdateOptions {
|
|||
latestSnapshots = true,
|
||||
consolidatedResolution = false,
|
||||
cachedResolution = false,
|
||||
managedChecksums = false,
|
||||
resolverConverter = PartialFunction.empty,
|
||||
moduleResolvers = Map.empty
|
||||
)
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ trait BaseIvySpecification extends UnitSpec {
|
|||
val paths = IvyPaths(currentBase, Some(currentTarget))
|
||||
val other = Vector.empty
|
||||
val check = Vector.empty
|
||||
val managedChecksums = false
|
||||
val moduleConfs = Vector(ModuleConfiguration("*", chainResolver))
|
||||
val resCacheDir = currentTarget / "resolution-cache"
|
||||
new InlineIvyConfiguration(paths,
|
||||
|
|
@ -62,6 +63,7 @@ trait BaseIvySpecification extends UnitSpec {
|
|||
moduleConfs,
|
||||
None,
|
||||
check,
|
||||
managedChecksums,
|
||||
Some(resCacheDir),
|
||||
uo,
|
||||
log)
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ class CustomPomParserTest extends UnitSpec {
|
|||
Vector.empty,
|
||||
None,
|
||||
Vector("sha1", "md5"),
|
||||
false,
|
||||
None,
|
||||
UpdateOptions(),
|
||||
log)
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ class ManagedChecksumsSpec extends BaseIvySpecification with DependencyBuilders
|
|||
moduleConfs,
|
||||
None,
|
||||
check,
|
||||
managedChecksums = true,
|
||||
Some(resCacheDir),
|
||||
uo,
|
||||
log)
|
||||
|
|
@ -63,7 +64,7 @@ class ManagedChecksumsSpec extends BaseIvySpecification with DependencyBuilders
|
|||
|
||||
"Managed checksums" should "should download the checksum files" in {
|
||||
cleanAll()
|
||||
val updateOptions = UpdateOptions().withManagedChecksums(true)
|
||||
val updateOptions = UpdateOptions()
|
||||
val toResolve = module(defaultModuleId, dependencies, None, updateOptions)
|
||||
val res = IvyActions.updateEither(toResolve, onlineConf, warningConf, noClock, targetDir, log)
|
||||
assert(res.isRight, s"Resolution with managed checksums failed! $res")
|
||||
|
|
|
|||
Loading…
Reference in New Issue