Skip to content

Commit

Permalink
Update to lm 2.0.0-alpha13 for sjson-new
Browse files Browse the repository at this point in the history
  • Loading branch information
eed3si9n committed Nov 25, 2023
1 parent 7082f2a commit c3e792e
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 16 deletions.
21 changes: 20 additions & 1 deletion main-actions/src/main/scala/sbt/Sync.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,15 @@ import sbt.util.CacheImplicits._
import sbt.util.{ CacheStore, FileInfo }
import sbt.io.IO
import sbt.librarymanagement.LibraryManagementCodec
import sjsonnew.{ Builder, JsonFormat, Unbuilder, deserializationError }
import sjsonnew.{
Builder,
IsoString,
IsoStringLong,
JsonFormat,
PathOnlyFormats,
Unbuilder,
deserializationError,
}
import xsbti.{ FileConverter, VirtualFileRef }

/**
Expand Down Expand Up @@ -126,11 +134,20 @@ object Sync {
}
}

private lazy val fileIsoString: IsoString[File] =
val iso = summon[IsoStringLong[File]]
IsoString.iso(
(file: File) => iso.to(file)._1,
(s: String) => iso.from((s, 0)),
)

def writeInfo[F <: FileInfo](
store: CacheStore,
relation: Relation[File, File],
info: Map[File, F]
)(implicit infoFormat: JsonFormat[F]): Unit =
given IsoString[File] = fileIsoString
import PathOnlyFormats.given
store.write((relation, info))

def writeInfoVirtual[F <: FileInfo](
Expand Down Expand Up @@ -213,6 +230,8 @@ object Sync {
private def readUncaught[F <: FileInfo](
store: CacheStore
)(implicit infoFormat: JsonFormat[F]): RelationInfo[F] =
given IsoString[File] = fileIsoString
import PathOnlyFormats.given
store.read(default = (Relation.empty[File, File], Map.empty[File, F]))

private def readUncaughtVirtual[F <: FileInfo](
Expand Down
7 changes: 5 additions & 2 deletions main/src/main/scala/sbt/Defaults.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3043,7 +3043,10 @@ object Classpaths {
}
}).value,
moduleName := normalizedName.value,
ivyPaths := IvyPaths(baseDirectory.value, bootIvyHome(appConfiguration.value)),
ivyPaths := IvyPaths(
baseDirectory.value.toString,
bootIvyHome(appConfiguration.value).map(_.toString)
),
csrCacheDirectory := {
val old = csrCacheDirectory.value
val ac = appConfiguration.value
Expand All @@ -3055,7 +3058,7 @@ object Classpaths {
else if (ip.ivyHome == defaultIvyCache) old
else
ip.ivyHome match {
case Some(home) => home / "coursier-cache"
case Some(home) => new File(home) / "coursier-cache"
case _ => old
}
} else Classpaths.dummyCoursierDirectory(ac)
Expand Down
2 changes: 1 addition & 1 deletion main/src/main/scala/sbt/RemoteCache.scala
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ object RemoteCache {
val app = appConfiguration.value
val base = app.baseDirectory.getCanonicalFile
// base is used only to resolve relative paths, which should never happen
IvyPaths(base, localCacheDirectory.value)
IvyPaths(base.toString, localCacheDirectory.value.toString)
},
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ object CoursierRepositoriesTasks {
val result2 =
paths.ivyHome match {
case Some(ivyHome) =>
val ivyHomeUri = ivyHome.getPath
val ivyHomeUri = ivyHome
result1 map {
case r: FileRepository =>
val ivyPatterns = r.patterns.ivyPatterns map {
Expand Down
6 changes: 3 additions & 3 deletions main/src/main/scala/sbt/coursierint/LMCoursier.scala
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ object LMCoursier {
createLogger: Option[CacheLogger],
cacheDirectory: File,
reconciliation: Seq[(ModuleMatchers, Reconciliation)],
ivyHome: Option[File],
ivyHome: Option[String],
strict: Option[CStrict],
depsOverrides: Seq[ModuleID],
log: Logger
Expand Down Expand Up @@ -140,7 +140,7 @@ object LMCoursier {
createLogger: Option[CacheLogger],
cacheDirectory: File,
reconciliation: Seq[(ModuleMatchers, Reconciliation)],
ivyHome: Option[File],
ivyHome: Option[String],
strict: Option[CStrict],
depsOverrides: Seq[ModuleID],
updateConfig: Option[UpdateConfiguration],
Expand Down Expand Up @@ -192,7 +192,7 @@ object LMCoursier {
.withCache(cacheDirectory)
.withReconciliation(reconciliation.toVector)
.withLog(log)
.withIvyHome(ivyHome)
.withIvyHome(ivyHome.map(new File(_)))
.withStrict(strict)
.withForceVersions(userForceVersions.toVector)
.withMissingOk(missingOk)
Expand Down
9 changes: 5 additions & 4 deletions main/src/main/scala/sbt/internal/LibraryManagement.scala
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ private[sbt] object LibraryManagement {
!force &&
!depsUpdated &&
!inChanged &&
out.allFiles.forall(f => fileUptodate(f, out.stamps, log)) &&
fileUptodate(out.cachedDescriptor, out.stamps, log)
out.allFiles.forall(f => fileUptodate(f.toString, out.stamps, log)) &&
fileUptodate(out.cachedDescriptor.toString, out.stamps, log)
}

/* Skip resolve if last output exists, otherwise error. */
Expand Down Expand Up @@ -166,7 +166,8 @@ private[sbt] object LibraryManagement {
handler((extraInputHash, settings, withoutClock))
}

private[this] def fileUptodate(file: File, stamps: Map[File, Long], log: Logger): Boolean = {
private[this] def fileUptodate(file0: String, stamps: Map[String, Long], log: Logger): Boolean = {
val file = File(file0)
val exists = file.exists
// https://github.com/sbt/sbt/issues/5292 warn the user that the file is missing since this indicates
// that UpdateReport was persisted but Coursier cache was not.
Expand All @@ -175,7 +176,7 @@ private[sbt] object LibraryManagement {
}
// coursier doesn't populate stamps
val timeStampIsSame = stamps
.get(file)
.get(file0)
.forall(_ == IO.getModifiedTimeOrZero(file))
exists && timeStampIsSame
}
Expand Down
4 changes: 3 additions & 1 deletion main/src/main/scala/sbt/internal/Load.scala
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ private[sbt] object Load {
Attributed.blankSeq(provider.mainClasspath.toIndexedSeq ++ scalaProvider.jars.toIndexedSeq)
val ivyConfiguration =
InlineIvyConfiguration()
.withPaths(IvyPaths(baseDirectory, bootIvyHome(state.configuration)))
.withPaths(
IvyPaths(baseDirectory.toString, bootIvyHome(state.configuration).map(_.toString))
)
.withResolvers(Resolver.combineDefaultResolvers(Vector.empty))
.withLog(log)
val dependencyResolution = IvyDependencyResolution(ivyConfiguration)
Expand Down
4 changes: 2 additions & 2 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ object Dependencies {
// sbt modules
private val ioVersion = nightlyVersion.getOrElse("1.8.0")
private val lmVersion =
sys.props.get("sbt.build.lm.version").orElse(nightlyVersion).getOrElse("2.0.0-alpha12")
sys.props.get("sbt.build.lm.version").orElse(nightlyVersion).getOrElse("2.0.0-alpha13")
val zincVersion = nightlyVersion.getOrElse("2.0.0-alpha6")

private val sbtIO = "org.scala-sbt" %% "io" % ioVersion
Expand Down Expand Up @@ -82,7 +82,7 @@ object Dependencies {
// val lmCoursierShaded = "io.get-coursier" %% "lm-coursier-shaded" % "2.0.10"
val lmCoursierShaded = "org.scala-sbt" %% "librarymanagement-coursier" % "2.0.0-alpha6"

lazy val sjsonNewVersion = "0.13.0"
lazy val sjsonNewVersion = "0.14.0-M1"
def sjsonNew(n: String) = Def.setting(
"com.eed3si9n" %% n % sjsonNewVersion
) // contrabandSjsonNewVersion.value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ abstract class IvyBridgeProviderSpecification
val resolvers = resolvers0.toVector
val chainResolver = ChainedResolver("zinc-chain", resolvers)
InlineIvyConfiguration()
.withPaths(IvyPaths(baseDirectory, Some(ivyHome)))
.withPaths(IvyPaths(baseDirectory.toString, Some(ivyHome.toString)))
.withResolvers(resolvers)
.withModuleConfigurations(Vector(ModuleConfiguration("*", chainResolver)))
.withLock(None)
Expand Down

0 comments on commit c3e792e

Please sign in to comment.