Merge pull request #7440 from eed3si9n/wip/basic-upkeep

This commit is contained in:
eugene yokota 2023-11-27 09:00:58 -05:00 committed by GitHub
commit ff48bbfe8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
66 changed files with 218 additions and 137 deletions

1
.gitignore vendored
View File

@ -16,3 +16,4 @@ npm-debug.log
metals.sbt
launcher-package/citest/freshly-baked
.vscode
sbt-launch.jar

1
.jvmopts Normal file
View File

@ -0,0 +1 @@
-Xmx2G

View File

@ -1,4 +1,4 @@
version = 3.6.0
version = 3.7.14
runner.dialect = scala3
maxColumn = 100
@ -26,5 +26,6 @@ trailingCommas = preserve
# TODO update scalafmt and enable Scala 3
project.excludeFilters = [
"internal/util-position/src/main/scala-3/sbt/internal/util/SourcePositionMacro.scala"
"internal/util-position/src/main/scala-3/sbt/internal/util/SourcePositionMacro.scala",
"main-settings/src/main/scala/sbt/Def.scala",
]

View File

@ -10,7 +10,7 @@ import scala.util.Try
// ThisBuild settings take lower precedence,
// but can be shared across the multi projects.
ThisBuild / version := {
val v = "2.0.0-alpha6-SNAPSHOT"
val v = "2.0.0-alpha8-SNAPSHOT"
nightlyVersion.getOrElse(v)
}
ThisBuild / version2_13 := "2.0.0-alpha1-SNAPSHOT"
@ -950,6 +950,8 @@ lazy val mainProj = (project in file("main"))
Test / testOptions += Tests
.Argument(TestFrameworks.ScalaCheck, "-minSuccessfulTests", "1000"),
SettingKey[Boolean]("usePipelining") := false,
// TODO: Fix doc
Compile / doc / sources := Nil,
// mimaSettings,
// mimaBinaryIssueFilters ++= Vector(),
)

View File

@ -387,11 +387,12 @@ object Eval:
tree match
case tpd.ValDef(name, tpt, _)
if isTopLevelModule(tree.symbol.owner) && isAcceptableType(tpt.tpe) =>
vals ::= name.mangledString
case tpd.ValDef(name, tpt, _) if name.mangledString.contains("$lzy") =>
val str = name.mangledString
vals ::= (
if str.contains("$lzy") then str.take(str.indexOf("$"))
else str
)
val methodName = str.take(str.indexOf("$"))
val m = tree.symbol.owner.requiredMethod(methodName)
if isAcceptableType(m.info) then vals ::= methodName
case t: tpd.Template => this((), t.body)
case t: tpd.PackageDef => this((), t.stats)
case t: tpd.TypeDef => this((), t.rhs)

View File

@ -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 }
/**
@ -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](
@ -145,7 +162,6 @@ object Sync {
fileConverter.toVirtualFile(file.toPath) -> fileInfo
}
import LibraryManagementCodec._
import sjsonnew.IsoString
implicit def virtualFileRefStringIso: IsoString[VirtualFileRef] =
IsoString.iso[VirtualFileRef](_.toString, VirtualFileRef.of(_))
@ -213,6 +229,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](

View File

@ -57,7 +57,7 @@ object Append:
override def appendValue(a: List[A1], b: V): List[A1] = a :+ (b: A1)
given appendVectorImplicit[A1, V](using ev: Conversion[V, A1]): Sequence[Vector[A1], Vector[V], V]
with
with
override def appendValues(a: Vector[A1], b: Vector[V]): Vector[A1] = a ++ b.map(x => (x: A1))
override def appendValue(a: Vector[A1], b: V): Vector[A1] = a :+ (b: A1)

View File

@ -27,7 +27,8 @@ private[sbt] final class Previous(streams: Streams, referenced: IMap[Previous.Ke
// We can't use mapValues to transform the map because mapValues is lazy and evaluates the
// transformation function every time a value is fetched from the map, defeating the entire
// purpose of ReferencedValue.
for (referenced.TPair(k, v) <- referenced.toTypedSeq) map = map.put(k, new ReferencedValue(v))
for case referenced.TPair(k, v) <- referenced.toTypedSeq do
map = map.put(k, new ReferencedValue(v))
private[this] final class ReferencedValue[T](referenced: Referenced[T]) {
lazy val previousValue: Option[T] = referenced.read(streams)
@ -122,10 +123,10 @@ object Previous {
// We first collect all of the successful tasks and write their scoped key into a map
// along with their values.
val successfulTaskResults = (for {
results.TPair(task, Result.Value(v)) <- results.toTypedSeq
val successfulTaskResults = (for
case results.TPair(task, Result.Value(v)) <- results.toTypedSeq
key <- task.info.attributes.get(Def.taskDefinitionKey).asInstanceOf[Option[AnyTaskKey]]
} yield key -> v).toMap
yield key -> v).toMap
// We then traverse the successful results and look up all of the referenced values for
// each of these tasks. This can be a many to one relationship if multiple tasks refer
// the previous value of another task. For each reference we find, we check if the task has

View File

@ -373,6 +373,8 @@ object Scoped:
}
private[sbt] trait Syntax:
// format: off
// richInitialize
extension [A1](init: Initialize[A1])
@targetName("mapTaskInitialize")
@ -380,6 +382,7 @@ object Scoped:
@targetName("flatMapValueInitialize")
def flatMapTaskValue[A2](f: A1 => Task[A2]): Initialize[Task[A2]] = init(f)
// format: on
// richInitializeTask
extension [A1](init: Initialize[Task[A1]])

View File

@ -2523,12 +2523,11 @@ object Defaults extends BuildCommon {
mappers.foldRight({ (p: Position) =>
withAbsoluteSource(p) // Fallback if sourcePositionMappers is empty
}) {
(mapper, previousPosition) =>
{ (p: Position) =>
// To each mapper we pass the position with the absolute source (only if reportAbsolutePath = true of course)
mapper(withAbsoluteSource(p)).getOrElse(previousPosition(p))
}
}) { (mapper, previousPosition) =>
{ (p: Position) =>
// To each mapper we pass the position with the absolute source (only if reportAbsolutePath = true of course)
mapper(withAbsoluteSource(p)).getOrElse(previousPosition(p))
}
}
}
@ -3044,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
@ -3056,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)

View File

@ -396,9 +396,8 @@ object EvaluateTask {
}
import ExceptionCategory._
for {
(key, msg, Some(ex)) <- keyed
} do
for case (key, msg, Some(ex)) <- keyed
do
def log = getStreams(key, streams).log
ExceptionCategory(ex) match {
case AlreadyHandled => ()

View File

@ -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)
},
)

View File

@ -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 {

View File

@ -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
@ -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],
@ -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)

View File

@ -335,19 +335,16 @@ private[sbt] object ClasspathImpl {
conf: Configuration,
data: Settings[Scope],
deps: BuildDependencies
): Seq[(ProjectRef, String)] = {
): Seq[(ProjectRef, String)] =
val visited = (new LinkedHashSet[(ProjectRef, String)]).asScala
def visit(p: ProjectRef, c: Configuration): Unit = {
def visit(p: ProjectRef, c: Configuration): Unit =
val applicableConfigs = allConfigs(c)
for {
ac <- applicableConfigs
} // add all configurations in this project
for ac <- applicableConfigs do
// add all configurations in this project
visited add (p -> ac.name)
val masterConfs = names(getConfigurations(projectRef, data).toVector)
for {
ClasspathDep.ResolvedClasspathDependency(dep, confMapping) <- deps.classpath(p)
} {
for case ClasspathDep.ResolvedClasspathDependency(dep, confMapping) <- deps.classpath(p) do
val configurations = getConfigurations(dep, data)
val mapping =
mapped(
@ -358,21 +355,15 @@ private[sbt] object ClasspathImpl {
"*->compile"
)
// map master configuration 'c' and all extended configurations to the appropriate dependency configuration
for {
for
ac <- applicableConfigs
depConfName <- mapping(ac.name)
} {
for {
depConf <- confOpt(configurations, depConfName)
} if (!visited((dep, depConfName))) {
visit(dep, depConf)
}
}
}
}
do
for depConf <- confOpt(configurations, depConfName) do
if !visited((dep, depConfName)) then visit(dep, depConf)
visit(projectRef, conf)
visited.toSeq
}
end interSort
def mapped(
confString: Option[String],

View File

@ -23,6 +23,7 @@ import scala.quoted.*
*/
object FileChangesMacro:
// format: off
extension [A](in: TaskKey[A])
@compileTimeOnly(
"`inputFileChanges` can only be called on a task within a task definition macro, such as :=, +=, ++=, or Def.task."
@ -47,7 +48,7 @@ object FileChangesMacro:
)
inline def outputFiles: Seq[NioPath] =
${ FileChangesMacro.outputFilesImpl[A]('in) }
// format: on
def changedInputFilesImpl[A: Type](in: Expr[TaskKey[A]])(using qctx: Quotes): Expr[FileChanges] =
impl[A](
in = in,

View File

@ -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. */
@ -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.
@ -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
}

View File

@ -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)

View File

@ -22,7 +22,9 @@ private[sbt] final case class LangServerError(code: Long, message: String)
private[sbt] object LanguageServerProtocol {
private val internalJsonProtocol = new sbt.internal.langserver.codec.JsonProtocol
with sbt.protocol.codec.JsonProtocol with sjsonnew.BasicJsonProtocol with InitializeOptionFormats
with sbt.protocol.codec.JsonProtocol
with sjsonnew.BasicJsonProtocol
with InitializeOptionFormats
import internalJsonProtocol._

View File

@ -6,7 +6,7 @@ object Dependencies {
// WARNING: Please Scala update versions in PluginCross.scala too
val scala212 = "2.12.17"
val scala213 = "2.13.8"
val scala3 = "3.2.1"
val scala3 = "3.3.1"
val checkPluginCross = settingKey[Unit]("Make sure scalaVersion match up")
val baseScalaVersion = scala3
def nightlyVersion: Option[String] =
@ -15,8 +15,8 @@ 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-alpha11")
val zincVersion = nightlyVersion.getOrElse("2.0.0-alpha6")
sys.props.get("sbt.build.lm.version").orElse(nightlyVersion).getOrElse("2.0.0-alpha13")
val zincVersion = nightlyVersion.getOrElse("2.0.0-alpha8")
private val sbtIO = "org.scala-sbt" %% "io" % ioVersion
@ -80,9 +80,9 @@ object Dependencies {
def addSbtZincCompileCore = addSbtModule(sbtZincPath, "zincCompileCore", zincCompileCore)
// val lmCoursierShaded = "io.get-coursier" %% "lm-coursier-shaded" % "2.0.10"
val lmCoursierShaded = "org.scala-sbt" %% "librarymanagement-coursier" % "2.0.0-alpha5"
val lmCoursierShaded = "org.scala-sbt" %% "librarymanagement-coursier" % "2.0.0-alpha7"
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

View File

@ -1 +1 @@
sbt.version=1.8.0
sbt.version=1.9.7

View File

@ -19,7 +19,7 @@ lazy val Dev = config("dev").extend(Compile)
lazy val root = (project in file("."))
.configs(Dev)
.settings(
ivyPaths := IvyPaths(baseDirectory.value, Some(target.value / "ivy-cache")),
ivyPaths := IvyPaths(baseDirectory.value.toString, Some((target.value / "ivy-cache").toString)),
publishTo := Some(Resolver.file("Test Publish Repo", file("test-repo"))),
scalaCompilerBridgeResolvers += userLocalFileResolver(appConfiguration.value),
resolvers += baseDirectory { base => "Test Repo" at (base / "test-repo").toURI.toString }.value,

View File

@ -7,7 +7,7 @@ ThisBuild / useCoursier := false
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
def localCache =
ivyPaths := IvyPaths(baseDirectory.value, Some((ThisBuild / baseDirectory).value / "ivy" / "cache"))
ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
val b = project
.settings(

View File

@ -1,2 +1,2 @@
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
ivyPaths := { IvyPaths(baseDirectory.value, Some(target.value / ".ivy2")) }
ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))

View File

@ -11,7 +11,7 @@ $ copy-file changes/use.sbt build.sbt
> update
> update
$ delete target/.ivy2/local
$ delete ivy/cache/local
-> update
$ copy-file changes/resolver.sbt resolver.sbt

View File

@ -1,8 +1,6 @@
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
ThisBuild / ivyPaths := {
val base = (ThisBuild / baseDirectory).value
IvyPaths(base, Some(base / "ivy-cache"))
}
ThisBuild / ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
ThisBuild / managedScalaInstance := false
ThisBuild / autoScalaLibrary := false
ThisBuild / crossPaths := false
ivyPaths := (ThisBuild / ivyPaths).value

View File

@ -2,6 +2,9 @@ ThisBuild / scalaVersion := "2.10.4"
ThisBuild / dependencyOverrides += "com.github.nscala-time" %% "nscala-time" % "1.0.0"
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
def localCache =
ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
lazy val root = (project in file("."))
.dependsOn(p1 % Compile)
.settings(
@ -22,10 +25,7 @@ lazy val root = (project in file("."))
description := "An HTTP client for Scala with Async Http Client underneath.",
licenses := Seq("Apache 2" -> new URL("http://www.apache.org/licenses/LICENSE-2.0.txt")),
)),
ivyPaths := IvyPaths(
(ThisBuild / baseDirectory).value,
Some((LocalRootProject / baseDirectory).value / "ivy-cache")
),
localCache,
libraryDependencies += "com.github.nscala-time" %% "nscala-time" % "1.0.0",
// https://github.com/sbt/sbt/pull/1620

View File

@ -10,9 +10,12 @@ ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-c
ThisBuild / organization := "org.example"
ThisBuild / version := "1.0-SNAPSHOT"
def localCache =
ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
def commonSettings: Seq[Def.Setting[_]] =
Seq(
ivyPaths := IvyPaths((ThisBuild / baseDirectory).value, Some((LocalRootProject / target).value / "ivy-cache")),
localCache,
scalaVersion := "2.10.4",
fullResolvers := fullResolvers.value.filterNot(_.name == "inter-project"),
updateOptions := updateOptions.value.withCachedResolution(true)

View File

@ -8,9 +8,12 @@ val akkaVersion = "2.3.1"
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
def localCache =
ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
def commonSettings: Seq[Def.Setting[_]] =
Seq(
ivyPaths := IvyPaths( (ThisBuild / baseDirectory).value, Some((LocalRootProject / target).value / "ivy-cache")),
localCache,
scalaVersion := "2.10.4",
fullResolvers := fullResolvers.value.filterNot(_.name == "inter-project")
)

View File

@ -4,9 +4,12 @@ lazy val check = taskKey[Unit]("Runs the check")
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
def localCache =
ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
def commonSettings: Seq[Def.Setting[_]] =
Seq(
ivyPaths := IvyPaths((ThisBuild / baseDirectory).value, Some((LocalRootProject / target).value / "ivy-cache")),
localCache,
dependencyCacheDirectory := (LocalRootProject / baseDirectory).value / "dependency",
scalaVersion := "2.10.4",
resolvers += Resolver.sonatypeRepo("snapshots")

View File

@ -3,10 +3,13 @@ import xsbti.AppConfiguration
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
ThisBuild / scalaVersion := "2.12.17"
def localCache =
ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
def commonSettings: Vector[Def.Setting[_]] =
Vector(
organization := "com.example",
ivyPaths := IvyPaths((ThisBuild / baseDirectory).value, Some((LocalRootProject / target).value / "ivy-cache")),
localCache,
dependencyCacheDirectory := (LocalRootProject / baseDirectory).value / "dependency",
scalaCompilerBridgeResolvers += userLocalFileResolver(appConfiguration.value),
resolvers += Resolver.file("buggy", (LocalRootProject / baseDirectory).value / "repo")(

View File

@ -10,8 +10,11 @@ inThisBuild(Seq(
updateOptions := updateOptions.value.withCachedResolution(true)
))
def localCache =
ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
def commonSettings: Seq[Def.Setting[_]] = Seq(
ivyPaths := IvyPaths((ThisBuild / baseDirectory).value, Some((LocalRootProject / target).value / "ivy-cache")),
localCache,
dependencyCacheDirectory := (LocalRootProject / baseDirectory).value / "dependency",
fullResolvers := fullResolvers.value.filterNot(_.name == "inter-project")
)

View File

@ -4,9 +4,12 @@ lazy val check = taskKey[Unit]("Runs the check")
ThisBuild / useCoursier := false
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
def localCache =
ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
def commonSettings: Seq[Def.Setting[_]] =
Seq(
ivyPaths := IvyPaths((ThisBuild / baseDirectory).value, Some((LocalRootProject / target).value / "ivy-cache")),
localCache,
dependencyCacheDirectory := (LocalRootProject / baseDirectory).value / "dependency",
scalaVersion := "2.10.4",
resolvers += Resolver.sonatypeRepo("snapshots")

View File

@ -2,9 +2,12 @@ lazy val check = taskKey[Unit]("Runs the check")
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
def localCache =
ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
def commonSettings: Seq[Def.Setting[_]] =
Seq(
ivyPaths := IvyPaths((ThisBuild / baseDirectory).value, Some((LocalRootProject / target).value / "ivy-cache")),
localCache,
dependencyCacheDirectory := (LocalRootProject / baseDirectory).value / "dependency",
scalaVersion := "2.10.4",
resolvers += Resolver.sonatypeRepo("snapshots")

View File

@ -6,9 +6,12 @@ val junit = "junit" % "junit" % "4.13.1"
ThisBuild / scalaVersion := "2.12.12"
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
def localCache =
ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
def commonSettings: Seq[Def.Setting[_]] =
Seq(
ivyPaths := IvyPaths((ThisBuild / baseDirectory).value, Some((LocalRootProject / target).value / "ivy-cache")),
localCache,
dependencyCacheDirectory := (LocalRootProject / baseDirectory).value / "dependency",
resolvers += Resolver.sonatypeRepo("snapshots")
)

View File

@ -4,9 +4,12 @@ ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-c
ThisBuild / organization := "org.example"
ThisBuild / version := "1.0"
def localCache =
ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
def commonSettings: Seq[Def.Setting[_]] =
Seq(
ivyPaths := IvyPaths((ThisBuild / baseDirectory).value, Some((LocalRootProject / target).value / "ivy-cache")),
localCache,
dependencyCacheDirectory := (LocalRootProject / baseDirectory).value / "dependency",
libraryDependencies := Seq(
"net.databinder" %% "unfiltered-uploads" % "0.8.0",

View File

@ -2,9 +2,12 @@ lazy val check = taskKey[Unit]("Runs the check")
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
def localCache =
ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
def commonSettings: Seq[Def.Setting[_]] =
Seq(
ivyPaths := IvyPaths((ThisBuild / baseDirectory).value, Some((LocalRootProject / target).value / "ivy-cache")),
localCache,
ThisBuild / scalaVersion := "2.11.12",
ThisBuild / organization := "com.example",
ThisBuild / version := "0.1.0-SNAPSHOT",

View File

@ -3,9 +3,12 @@ ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-c
lazy val check = taskKey[Unit]("Runs the check")
def localCache =
ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
def commonSettings: Seq[Def.Setting[_]] =
Seq(
ivyPaths := IvyPaths( (ThisBuild / baseDirectory).value, Some((LocalRootProject / target).value / "ivy-cache")),
localCache,
scalaVersion := "2.10.4",
fullResolvers := fullResolvers.value.filterNot(_.name == "inter-project"),
updateOptions := updateOptions.value.withCircularDependencyLevel(CircularDependencyLevel.Error)

View File

@ -2,9 +2,12 @@ lazy val check = taskKey[Unit]("Runs the check")
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
def localCache =
ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
def commonSettings: Seq[Def.Setting[_]] =
Seq(
ivyPaths := IvyPaths((ThisBuild / baseDirectory).value, Some((LocalRootProject / target).value / "ivy-cache")),
localCache,
scalaVersion := "2.10.4",
fullResolvers := fullResolvers.value.filterNot(_.name == "inter-project")
)

View File

@ -1,4 +1,4 @@
ivyPaths := IvyPaths(baseDirectory.value, Some(target.value / "ivy-cache"))
ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
libraryDependencies += "org.testng" % "testng" % "5.7" classifier "jdk15"

View File

@ -1,6 +1,6 @@
ThisBuild / scalaVersion := "2.13.0"
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
ivyPaths := IvyPaths(baseDirectory.value, Some(target.value / "ivy-cache"))
ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
// don't blow up when credential file doesn't exist
// https://github.com/sbt/sbt/issues/4882

View File

@ -14,8 +14,11 @@ lazy val b = project.settings(common: _*).settings(
libraryDependencies := Seq(organization.value %% "a" % version.value)
)
def localCache =
ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
lazy val common = Seq(
localCache,
autoScalaLibrary := false, // avoid downloading fresh scala-library/scala-compiler
managedScalaInstance := false,
ivyPaths := IvyPaths( (ThisBuild / baseDirectory).value, Some((LocalRootProject / target).value / "ivy-cache"))
)

View File

@ -1,9 +1,12 @@
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
ThisBuild / scalaVersion := "2.12.17"
def localCache =
ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
lazy val root = (project in file(".")).
settings(
ivyPaths := IvyPaths(baseDirectory.value, Some(target.value / "ivy-cache")),
localCache,
libraryDependencies += baseDirectory(transitive("javax.mail" % "mail" % "1.4.1")).value,
TaskKey[Unit]("checkTransitive") := check(true).value,
TaskKey[Unit]("checkIntransitive") := check(false).value

View File

@ -1,7 +1,11 @@
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
def localCache =
ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
lazy val root = (project in file("."))
.settings(
localCache,
organization := "com.example",
version := "1.0",
name := "define-color",
@ -9,7 +13,6 @@ lazy val root = (project in file("."))
val old = projectID.value
old.extra("e:color" -> "red")
},
ivyPaths := IvyPaths(baseDirectory.value, Some(target.value / "ivy-cache")),
publishMavenStyle := false,
publishTo := {
val base = baseDirectory.value

View File

@ -1,13 +1,16 @@
ThisBuild / useCoursier := false
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
def localCache =
ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
lazy val root = (project in file("."))
.settings(
localCache,
organization := "org.example",
name := "use-color",
ivyPaths := IvyPaths(baseDirectory.value, Some(target.value / "ivy-cache")),
publishMavenStyle := false,
resolvers := baseDirectory( base =>
resolvers := baseDirectory( base =>
Resolver.file("test-repo", base / "repo" / "test")(Resolver.defaultIvyPatterns) :: Nil
).value,
libraryDependencies := {

View File

@ -2,12 +2,15 @@ ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-c
lazy val root = (project in file(".")).
settings(
ivyPaths := IvyPaths(baseDirectory.value, Some(target.value / "ivy-cache")),
localCache,
libraryDependencies ++= baseDirectory (libraryDeps).value,
TaskKey[Unit]("checkForced") := check("1.2.14").value,
TaskKey[Unit]("checkDepend") := check("1.2.13").value
)
def localCache =
ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
def libraryDeps(base: File) = {
val slf4j = Seq("org.slf4j" % "slf4j-log4j12" % "1.1.0") // Uses log4j 1.2.13
if ((base / "force").exists) slf4j :+ ("log4j" % "log4j" % "1.2.14").force() else slf4j

View File

@ -3,9 +3,12 @@ ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-c
import scala.xml._
def localCache =
ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
lazy val root = (project in file(".")).
settings(
ivyPaths := IvyPaths(baseDirectory.value, Some(target.value / "ivy-cache")),
localCache,
ivyXML := inlineXML(customInfo.value, organization.value, moduleName.value, version.value),
scalaVersion := "2.9.1",
projectID ~= (_ cross false),

View File

@ -1,9 +1,8 @@
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
libraryDependencies += "org.scalacheck" % "scalacheck" % "1.5"
ivyPaths := baseDirectory( dir => IvyPaths(dir, Some(dir / "ivy-home"))).value
TaskKey[Unit]("check") := {
val report = update.value
val files = report.matching( moduleFilter(organization = "org.scalacheck", name = "scalacheck", revision = "1.5") )

View File

@ -1,7 +1,5 @@
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
ivyPaths := IvyPaths(baseDirectory.value, Some(target.value / ".ivy2"))
// not in the default repositories
libraryDependencies += "com.sun.jmx" % "jmxri" % "1.2.1"

View File

@ -1,6 +1,5 @@
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
ivyPaths := IvyPaths(baseDirectory.value, Some(target.value / "ivy-cache"))
ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
organization := "org.example"

View File

@ -2,8 +2,6 @@ ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-c
autoScalaLibrary := false
ivyPaths := IvyPaths(baseDirectory.value, Some(target.value / "ivy-cache"))
scalaModuleInfo := Some(sbt.librarymanagement.ScalaModuleInfo(
(update / scalaVersion).value,
(update / scalaBinaryVersion).value,

View File

@ -5,11 +5,17 @@ platform := Platform.sjs1
// By default platformOpt field is set to None
// Given %% lm engines will sustitute it with the subproject's platform suffix on `update`
libraryDependencies += "com.github.scopt" %% "scopt" % "4.1.0"
libraryDependencies ++= Seq(
"com.github.scopt" %% "scopt" % "4.1.0",
"junit" % "junit" % "4.13.1",
)
TaskKey[Unit]("check") := {
val ur = update.value
val files = ur.matching(moduleFilter(organization = "com.github.scopt", name = "scopt_sjs1_2.13", revision = "*"))
assert(files.nonEmpty, s"sjs1 scopt module was not found in update report: $ur")
val files2 = ur.matching(moduleFilter(organization = "junit", name = "junit", revision = "*"))
assert(files2.nonEmpty, s"junit module was not found in update report: $ur")
}
csrCacheDirectory := baseDirectory.value / "coursier-cache"

View File

@ -3,10 +3,13 @@ ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-c
val checkIvyXml = taskKey[Unit]("Checks the ivy.xml transform was correct")
lazy val root = (project in file(".")).
settings(
def localCache =
ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
lazy val root = (project in file("."))
.settings(
localCache,
name := "test-parent-pom",
ivyPaths := IvyPaths( (ThisBuild / baseDirectory).value, Some((LocalRootProject / target).value / "ivy-cache")),
resolvers += MavenCache("Maven2 Local Test", baseDirectory.value / "local-repo"),
libraryDependencies += "com.example" % "example-child" % "1.0-SNAPSHOT",
libraryDependencies += "org.apache.geronimo.specs" % "geronimo-jta_1.1_spec" % "1.1.1",

View File

@ -2,9 +2,8 @@ ThisBuild / organization := "com.example"
ThisBuild / scalaVersion := "2.12.12"
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
def customIvyPaths: Seq[Def.Setting[_]] = Seq(
ivyPaths := IvyPaths((ThisBuild / baseDirectory).value, Some((ThisBuild / baseDirectory).value / "ivy-cache"))
)
def localCache =
ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
lazy val sharedResolver: Resolver = {
val r = Resolver.defaultShared
@ -14,7 +13,7 @@ lazy val sharedResolver: Resolver = {
}
lazy val common = project
.settings(customIvyPaths)
.settings(localCache)
.settings(
organization := "com.badexample",
name := "badexample",
@ -30,7 +29,7 @@ lazy val common = project
)
lazy val dependent = project
.settings(customIvyPaths)
.settings(localCache)
.settings(
// Ignore the inter-project resolver, so we force to look remotely.
resolvers += sharedResolver,

View File

@ -5,9 +5,8 @@ ThisBuild / scalaVersion := "2.12.12"
ThisBuild / useCoursier := false
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
def customIvyPaths: Seq[Def.Setting[_]] = Seq(
ivyPaths := IvyPaths(baseDirectory.value, Some((ThisBuild / baseDirectory).value / "ivy" / "cache"))
)
def localCache =
ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
lazy val sharedResolver: Resolver = {
val r = Resolver.defaultShared
@ -17,7 +16,7 @@ lazy val sharedResolver: Resolver = {
}
lazy val common = project
.settings(customIvyPaths)
.settings(localCache)
.settings(
organization := "com.badexample",
name := "badexample",
@ -34,7 +33,7 @@ lazy val common = project
)
lazy val dependent = project
.settings(customIvyPaths)
.settings(localCache)
.settings(
// Uncomment the following to test the before/after
// updateOptions := updateOptions.value.withLatestSnapshots(false),

View File

@ -2,7 +2,7 @@ ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-c
autoScalaLibrary := false
ivyPaths := IvyPaths(baseDirectory.value, Some(target.value / "ivy-cache"))
ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
libraryDependencies ++= Seq(
"org.sat4j" % "org.sat4j.pb" % "2.3.1",

View File

@ -3,7 +3,7 @@ ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-c
ivyPaths := {
val base = baseDirectory.value
IvyPaths(base, Some(base / "ivy-cache"))
IvyPaths(base.toString, Some((base / "ivy-cache").toString))
}
managedScalaInstance := false

View File

@ -2,9 +2,12 @@ import sbt.internal.inc.classpath.ClasspathUtilities
ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"
def localCache =
ivyPaths := IvyPaths(baseDirectory.value.toString, Some(((ThisBuild / baseDirectory).value / "ivy" / "cache").toString))
lazy val root = (project in file(".")).
settings(
ivyPaths := IvyPaths(baseDirectory.value, Some(target.value / "ivy-cache")),
localCache,
libraryDependencies += "org.jsoup" % "jsoup" % "1.9.1" % Test from "https://jsoup.org/packages/jsoup-1.9.1.jar",
ivyLoggingLevel := UpdateLogging.Full,
TaskKey[Unit]("checkInTest") := checkClasspath(Test).value,

View File

@ -11,8 +11,7 @@ import java.io.File
import scala.util.control.NonFatal
import sbt.io.{ Hash, IO }
import sjsonnew.{ Builder, DeserializationException, JsonFormat, Unbuilder, deserializationError }
import CacheImplicits.{ arrayFormat => _, _ }
import sjsonnew.{ arrayFormat => _, _ }
import sbt.nio.file._
import sbt.nio.file.syntax._
@ -118,7 +117,7 @@ object FileInfo {
implicit val format: JsonFormat[HashModifiedFileInfo] = new JsonFormat[HashModifiedFileInfo] {
def write[J](obj: HashModifiedFileInfo, builder: Builder[J]) = {
builder.beginObject()
builder.addField("file", obj.file)
builder.addField("file", obj.file.toString)
builder.addField("hash", obj.hashArray)
builder.addField("lastModified", obj.lastModified)
builder.endObject()
@ -127,11 +126,11 @@ object FileInfo {
def read[J](jsOpt: Option[J], unbuilder: Unbuilder[J]) = jsOpt match {
case Some(js) =>
unbuilder.beginObject(js)
val file = unbuilder.readField[File]("file")
val file = unbuilder.readField[String]("file")
val hash = unbuilder.readField[Array[Byte]]("hash")
val lastModified = unbuilder.readField[Long]("lastModified")
unbuilder.endObject()
FileHashModifiedArrayRepr(file, hash, lastModified)
FileHashModifiedArrayRepr(new File(file), hash, lastModified)
case None => deserializationError("Expected JsObject but found None")
}
}
@ -148,7 +147,7 @@ object FileInfo {
implicit val format: JsonFormat[HashFileInfo] = new JsonFormat[HashFileInfo] {
def write[J](obj: HashFileInfo, builder: Builder[J]) = {
builder.beginObject()
builder.addField("file", obj.file)
builder.addField("file", obj.file.toString)
builder.addField("hash", obj.hashArray)
builder.endObject()
}
@ -156,10 +155,10 @@ object FileInfo {
def read[J](jsOpt: Option[J], unbuilder: Unbuilder[J]) = jsOpt match {
case Some(js) =>
unbuilder.beginObject(js)
val file = unbuilder.readField[File]("file")
val file = unbuilder.readField[String]("file")
val hash = unbuilder.readField[Array[Byte]]("hash")
unbuilder.endObject()
FileHashArrayRepr(file, hash)
FileHashArrayRepr(new File(file), hash)
case None => deserializationError("Expected JsObject but found None")
}
}
@ -182,18 +181,18 @@ object FileInfo {
jsOpt match {
case Some(js) =>
unbuilder.beginObject(js)
val file = unbuilder.readField[File]("file")
val lastModified = unbuilder.readField[Long]("lastModified")
val file = unbuilder.readField[String]("file")
val lastModified = unbuilder.readField[String]("lastModified").toLong
unbuilder.endObject()
FileModified(file, lastModified)
FileModified(new File(file), lastModified)
case None =>
deserializationError("Expected JsObject but found None")
}
override def write[J](obj: ModifiedFileInfo, builder: Builder[J]): Unit = {
builder.beginObject()
builder.addField("file", obj.file)
builder.addField("lastModified", obj.lastModified)
builder.addField[String]("file", obj.file.toString)
builder.addField[String]("lastModified", obj.lastModified.toString)
builder.endObject()
}
}
@ -232,7 +231,7 @@ object FileInfo {
implicit val format: JsonFormat[PlainFileInfo] = new JsonFormat[PlainFileInfo] {
def write[J](obj: PlainFileInfo, builder: Builder[J]): Unit = {
builder.beginObject()
builder.addField("file", obj.file)
builder.addField("file", obj.file.toString)
builder.addField("exists", obj.exists)
builder.endObject()
}
@ -240,10 +239,10 @@ object FileInfo {
def read[J](jsOpt: Option[J], unbuilder: Unbuilder[J]) = jsOpt match {
case Some(js) =>
unbuilder.beginObject(js)
val file = unbuilder.readField[File]("file")
val file = unbuilder.readField[String]("file")
val exists = unbuilder.readField[Boolean]("exists")
unbuilder.endObject()
PlainFile(file, exists)
PlainFile(new File(file), exists)
case None => deserializationError("Expected JsObject but found None")
}
}

View File

@ -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)