mirror of https://github.com/sbt/sbt.git
Merge pull request #3385 from eed3si9n/wip/contraband2
Bump modules, and use LM API
This commit is contained in:
commit
07879e26e1
|
|
@ -371,6 +371,10 @@ lazy val mainProj = (project in file("main"))
|
|||
// method scalaVersionFromSbtBinaryVersion(java.lang.String)java.lang.String in object sbt.Defaults does not have a correspondent in current version
|
||||
// Was private[sbt]
|
||||
ProblemFilters.exclude[DirectMissingMethodProblem]("sbt.Defaults.scalaVersionFromSbtBinaryVersion"),
|
||||
// AltLibraryManagementCodec was removed.
|
||||
ProblemFilters.exclude[MissingClassProblem]("sbt.internal.AltLibraryManagementCodec*"),
|
||||
// The signature of internal method changed. This is ok.
|
||||
ProblemFilters.exclude[IncompatibleMethTypeProblem]("sbt.internal.LibraryManagement.cachedUpdate"),
|
||||
)
|
||||
)
|
||||
.configure(
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ import scala.concurrent.duration.FiniteDuration
|
|||
import scala.util.control.NonFatal
|
||||
import scala.xml.NodeSeq
|
||||
import Scope.{ fillTaskAxis, GlobalScope, ThisScope }
|
||||
import sjsonnew.{ IsoLList, JsonFormat, LList, LNil }, LList.:*:
|
||||
import sjsonnew.{ IsoLList, JsonFormat, LList, LNil, :*: }
|
||||
import sjsonnew.shaded.scalajson.ast.unsafe.JValue
|
||||
import std.TaskExtra._
|
||||
import testing.{ Framework, Runner, AnnotatedFingerprint, SubclassFingerprint }
|
||||
|
|
@ -2295,16 +2295,18 @@ object Classpaths {
|
|||
}.value
|
||||
|
||||
LibraryManagement.cachedUpdate(
|
||||
// LM API
|
||||
lm = dependencyResolution.value,
|
||||
// Ivy-free ModuleDescriptor
|
||||
module = ivyModule.value,
|
||||
s.cacheStoreFactory.sub(updateCacheName.value),
|
||||
Reference.display(thisProjectRef.value),
|
||||
ivyModule.value,
|
||||
updateConf,
|
||||
substituteScalaFiles(scalaOrganization.value, _)(providedScalaJars),
|
||||
skip = (skip in update).value,
|
||||
force = shouldForce,
|
||||
depsUpdated = transitiveUpdate.value.exists(!_.stats.cached),
|
||||
uwConfig = (unresolvedWarningConfiguration in update).value,
|
||||
depDir = Some(dependencyCacheDirectory.value),
|
||||
ewo = evictionOptions,
|
||||
mavenStyle = publishMavenStyle.value,
|
||||
compatWarning = compatibilityWarningOptions.value,
|
||||
|
|
|
|||
|
|
@ -1,114 +0,0 @@
|
|||
package sbt.internal
|
||||
|
||||
import sbt.internal.librarymanagement._
|
||||
import sbt.internal.util.Types._
|
||||
import sbt.internal.util.{ HList, HNil }
|
||||
import sbt.io.Hash
|
||||
import sbt.librarymanagement._
|
||||
import sbt.librarymanagement.ivy._
|
||||
import sbt.util._
|
||||
import sbt.internal.util.HListFormats._
|
||||
import sjsonnew.JsonFormat
|
||||
|
||||
object AltLibraryManagementCodec extends IvyLibraryManagementCodec {
|
||||
type In0 = ModuleSettings :+: UpdateConfiguration :+: HNil
|
||||
type In = IvyConfiguration :+: In0
|
||||
|
||||
object NullLogger extends sbt.internal.util.BasicLogger {
|
||||
override def control(event: sbt.util.ControlEvent.Value, message: ⇒ String): Unit = ()
|
||||
override def log(level: Level.Value, message: ⇒ String): Unit = ()
|
||||
override def logAll(events: Seq[sbt.util.LogEvent]): Unit = ()
|
||||
override def success(message: ⇒ String): Unit = ()
|
||||
override def trace(t: ⇒ Throwable): Unit = ()
|
||||
}
|
||||
|
||||
implicit val altRawRepositoryJsonFormat: JsonFormat[RawRepository] =
|
||||
projectFormat(_.name, FakeRawRepository.create)
|
||||
|
||||
// Redefine to add RawRepository, and switch to unionFormat
|
||||
override lazy implicit val ResolverFormat: JsonFormat[Resolver] =
|
||||
unionFormat8[Resolver,
|
||||
ChainedResolver,
|
||||
MavenRepo,
|
||||
MavenCache,
|
||||
FileRepository,
|
||||
URLRepository,
|
||||
SshRepository,
|
||||
SftpRepository,
|
||||
RawRepository]
|
||||
|
||||
type InlineIvyHL = (Option[IvyPaths] :+: Vector[Resolver] :+: Vector[Resolver] :+: Vector[
|
||||
ModuleConfiguration] :+: Vector[String] :+: Boolean :+: HNil)
|
||||
def inlineIvyToHL(i: InlineIvyConfiguration): InlineIvyHL = (
|
||||
i.paths :+: i.resolvers :+: i.otherResolvers :+: i.moduleConfigurations :+:
|
||||
i.checksums :+: i.managedChecksums :+: HNil
|
||||
)
|
||||
|
||||
type ExternalIvyHL = Option[PlainFileInfo] :+: Array[Byte] :+: HNil
|
||||
def externalIvyToHL(e: ExternalIvyConfiguration): ExternalIvyHL =
|
||||
e.baseDirectory.map(FileInfo.exists.apply) :+: e.uri
|
||||
.map(Hash.contentsIfLocal)
|
||||
.getOrElse(Array.empty) :+: HNil
|
||||
|
||||
// Redefine to use a subset of properties, that are serialisable
|
||||
override lazy implicit val InlineIvyConfigurationFormat: JsonFormat[InlineIvyConfiguration] = {
|
||||
def hlToInlineIvy(i: InlineIvyHL): InlineIvyConfiguration = {
|
||||
val (paths :+: resolvers :+: otherResolvers :+: moduleConfigurations :+: checksums
|
||||
:+: managedChecksums :+: HNil) = i
|
||||
InlineIvyConfiguration()
|
||||
.withPaths(paths)
|
||||
.withResolvers(resolvers)
|
||||
.withOtherResolvers(otherResolvers)
|
||||
.withModuleConfigurations(moduleConfigurations)
|
||||
.withManagedChecksums(managedChecksums)
|
||||
.withChecksums(checksums)
|
||||
}
|
||||
|
||||
projectFormat[InlineIvyConfiguration, InlineIvyHL](inlineIvyToHL, hlToInlineIvy)
|
||||
}
|
||||
|
||||
// Redefine to use a subset of properties, that are serialisable
|
||||
override lazy implicit val ExternalIvyConfigurationFormat
|
||||
: JsonFormat[ExternalIvyConfiguration] = {
|
||||
def hlToExternalIvy(e: ExternalIvyHL): ExternalIvyConfiguration = {
|
||||
val baseDirectory :+: _ /* uri */ :+: HNil = e
|
||||
ExternalIvyConfiguration(
|
||||
None,
|
||||
Some(NullLogger),
|
||||
UpdateOptions(),
|
||||
baseDirectory.map(_.file),
|
||||
None /* the original uri is destroyed.. */,
|
||||
Vector.empty
|
||||
)
|
||||
}
|
||||
|
||||
projectFormat[ExternalIvyConfiguration, ExternalIvyHL](externalIvyToHL, hlToExternalIvy)
|
||||
}
|
||||
|
||||
// Redefine to switch to unionFormat
|
||||
override implicit lazy val IvyConfigurationFormat: JsonFormat[IvyConfiguration] =
|
||||
unionFormat2[IvyConfiguration, InlineIvyConfiguration, ExternalIvyConfiguration]
|
||||
|
||||
def forHNil[A <: HNil]: Equiv[A] = (_: A, _: A) => true
|
||||
implicit val lnilEquiv1: Equiv[HNil] = forHNil[HNil]
|
||||
implicit val lnilEquiv2: Equiv[HNil.type] = forHNil[HNil.type]
|
||||
|
||||
implicit def hconsEquiv[H, T <: HList](implicit he: Equiv[H], te: Equiv[T]): Equiv[H :+: T] =
|
||||
(x: H :+: T, y: H :+: T) => he.equiv(x.head, y.head) && te.equiv(x.tail, y.tail)
|
||||
|
||||
implicit object altIvyConfigurationEquiv extends Equiv[IvyConfiguration] {
|
||||
def equiv(x: IvyConfiguration, y: IvyConfiguration): Boolean = (x, y) match {
|
||||
case (x: InlineIvyConfiguration, y: InlineIvyConfiguration) =>
|
||||
implicitly[Equiv[InlineIvyHL]].equiv(inlineIvyToHL(x), inlineIvyToHL(y))
|
||||
case (x: ExternalIvyConfiguration, y: ExternalIvyConfiguration) =>
|
||||
implicitly[Equiv[ExternalIvyHL]].equiv(externalIvyToHL(x), externalIvyToHL(y))
|
||||
case (x: Any, y: Any) => sys error s"Trying to compare ${x.getClass} with ${y.getClass}"
|
||||
}
|
||||
}
|
||||
|
||||
implicit object altInSingletonCache extends SingletonCache[In] {
|
||||
def write(to: Output, value: In) = to.write(value)
|
||||
def read(from: Input) = from.read[In]()
|
||||
def equiv = hconsEquiv(altIvyConfigurationEquiv, implicitly[Equiv[In0]])
|
||||
}
|
||||
}
|
||||
|
|
@ -3,29 +3,25 @@ package sbt.internal
|
|||
import java.io.File
|
||||
|
||||
import sbt.internal.librarymanagement._
|
||||
import sbt.internal.util.HNil
|
||||
import sbt.internal.util.Types._
|
||||
import sbt.internal.util.HListFormats._
|
||||
import sbt.librarymanagement._
|
||||
import sbt.librarymanagement.ivy._
|
||||
import sbt.librarymanagement.syntax._
|
||||
import sbt.util.{ CacheStore, CacheStoreFactory, Logger, Tracked }
|
||||
|
||||
private[sbt] object LibraryManagement {
|
||||
|
||||
private type UpdateInputs = IvyConfiguration :+: ModuleSettings :+: UpdateConfiguration :+: HNil
|
||||
private type UpdateInputs = (Long, ModuleSettings, UpdateConfiguration)
|
||||
|
||||
def cachedUpdate(
|
||||
lm: DependencyResolution,
|
||||
module: ModuleDescriptor,
|
||||
cacheStoreFactory: CacheStoreFactory,
|
||||
label: String,
|
||||
module: IvySbt#Module,
|
||||
updateConfig: UpdateConfiguration,
|
||||
transform: UpdateReport => UpdateReport,
|
||||
skip: Boolean,
|
||||
force: Boolean,
|
||||
depsUpdated: Boolean,
|
||||
uwConfig: UnresolvedWarningConfiguration,
|
||||
depDir: Option[File],
|
||||
ewo: EvictionWarningOptions,
|
||||
mavenStyle: Boolean,
|
||||
compatWarning: CompatibilityWarningOptions,
|
||||
|
|
@ -39,7 +35,7 @@ private[sbt] object LibraryManagement {
|
|||
log.info(s"Updating $label...")
|
||||
val reportOrUnresolved: Either[UnresolvedWarning, UpdateReport] =
|
||||
//try {
|
||||
IvyActions.updateEither(module, updateConfig, uwConfig, /*logicalClock, depDir,*/ log)
|
||||
lm.update(module, updateConfig, uwConfig, log)
|
||||
// } catch {
|
||||
// case e: Throwable =>
|
||||
// e.printStackTrace
|
||||
|
|
@ -107,18 +103,19 @@ private[sbt] object LibraryManagement {
|
|||
}
|
||||
.apply(cachedResolve(updateInputs))
|
||||
}
|
||||
import AltLibraryManagementCodec._
|
||||
import LibraryManagementCodec._
|
||||
Tracked.inputChanged(cacheStoreFactory.make("inputs"))(doCachedResolve)
|
||||
}
|
||||
|
||||
// Get the handler to use and feed it in the inputs
|
||||
val ivyConfig = module.owner.configuration
|
||||
// This is lm-engine specific input hashed into Long
|
||||
val extraInputHash = module.extraInputHash
|
||||
val settings = module.moduleSettings
|
||||
val outStore = cacheStoreFactory.make("output")
|
||||
val handler = if (skip && !force) skipResolve(outStore) else doResolve(outStore)
|
||||
// Remove clock for caching purpose
|
||||
val withoutClock = updateConfig.withLogicalClock(LogicalClock.unknown)
|
||||
handler(ivyConfig :+: settings :+: withoutClock :+: HNil)
|
||||
handler((extraInputHash, settings, withoutClock))
|
||||
}
|
||||
|
||||
private[this] def fileUptodate(file: File, stamps: Map[File, Long]): Boolean =
|
||||
|
|
|
|||
|
|
@ -12,10 +12,10 @@ object Dependencies {
|
|||
val baseScalaVersion = scala212
|
||||
|
||||
// sbt modules
|
||||
private val ioVersion = "1.0.0-M12"
|
||||
private val utilVersion = "1.0.0-M28"
|
||||
private val lmVersion = "1.0.0-X18"
|
||||
private val zincVersion = "1.0.0-X20"
|
||||
private val ioVersion = "1.0.0-RC3"
|
||||
private val utilVersion = "1.0.0-RC3"
|
||||
private val lmVersion = "1.0.0-RC3"
|
||||
private val zincVersion = "1.0.0-RC3"
|
||||
|
||||
private val sbtIO = "org.scala-sbt" %% "io" % ioVersion
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,6 @@ addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.1.15")
|
|||
// addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.2.0")
|
||||
|
||||
addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.1")
|
||||
addSbtPlugin("org.scala-sbt" % "sbt-contraband" % "0.3.0-M9")
|
||||
addSbtPlugin("org.scala-sbt" % "sbt-contraband" % "0.3.0")
|
||||
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.0-M1")
|
||||
// addSbtPlugin("com.lucidchart" % "sbt-scalafmt" % "1.3")
|
||||
|
|
|
|||
|
|
@ -34,38 +34,33 @@ lazy val root = (project in file("."))
|
|||
val cacheStoreFactory = s.cacheStoreFactory sub updateCacheName.value
|
||||
val module = ivyModule.value
|
||||
val updateConfig = updateConfiguration.value
|
||||
val ivyConfiguration0 = module.owner.configuration
|
||||
val extraInputHash0 = module.extraInputHash
|
||||
val moduleSettings0 = module.moduleSettings
|
||||
val inline0 = moduleSettings0 match { case x: InlineConfiguration => x }
|
||||
// Remove clock for caching purpose
|
||||
val updateConfig0 = updateConfig.withLogicalClock(LogicalClock.unknown)
|
||||
|
||||
import sbt.librarymanagement.ivy.IvyConfiguration
|
||||
import sbt.librarymanagement.{ ModuleSettings, UpdateConfiguration }
|
||||
import sbt.internal.util.HListFormats._
|
||||
import sbt.librarymanagement.{ ModuleSettings, UpdateConfiguration, LibraryManagementCodec }
|
||||
type In = (Long, ModuleSettings, UpdateConfiguration)
|
||||
|
||||
type In = IvyConfiguration :+: ModuleSettings :+: UpdateConfiguration :+: HNil
|
||||
|
||||
import sbt.util.CacheImplicits._
|
||||
import sbt.internal.util.HListFormats._
|
||||
import sbt.internal.AltLibraryManagementCodec._
|
||||
import LibraryManagementCodec._
|
||||
|
||||
val f: In => Unit =
|
||||
Tracked.inputChanged(cacheStoreFactory make "inputs") { (inChanged: Boolean, in: In) =>
|
||||
val ivyConfiguration1 = in.head
|
||||
val moduleSettings1 = in.tail.head
|
||||
val extraInputHash1 = in._1
|
||||
val moduleSettings1 = in._2
|
||||
val inline1 = moduleSettings1 match { case x: InlineConfiguration => x }
|
||||
val updateConfig1 = in.tail.tail.head
|
||||
val updateConfig1 = in._3
|
||||
|
||||
if (inChanged) {
|
||||
sys.error(s"""
|
||||
ivyConfiguration1 == ivyConfiguration0: ${ivyConfiguration1 == ivyConfiguration0}
|
||||
extraInputHash1 == extraInputHash0: ${extraInputHash1 == extraInputHash0}
|
||||
|
||||
ivyConfiguration1:
|
||||
$ivyConfiguration1
|
||||
extraInputHash1:
|
||||
$extraInputHash1
|
||||
|
||||
ivyConfiguration0
|
||||
$ivyConfiguration0
|
||||
extraInputHash0
|
||||
$extraInputHash0
|
||||
-----
|
||||
inline1 == inline0: ${inline1 == inline0}
|
||||
|
||||
|
|
@ -86,7 +81,7 @@ $updateConfig0
|
|||
}
|
||||
}
|
||||
|
||||
f(ivyConfiguration0 :+: (inline0: ModuleSettings) :+: updateConfig0 :+: HNil)
|
||||
f((extraInputHash0, (inline0: ModuleSettings), updateConfig0))
|
||||
},
|
||||
|
||||
// https://github.com/sbt/sbt/issues/3226
|
||||
|
|
|
|||
Loading…
Reference in New Issue