mirror of https://github.com/sbt/sbt.git
Rename Files to Cache
This commit is contained in:
parent
064f495114
commit
9f26ed05b2
|
|
@ -234,7 +234,7 @@ case class Bootstrap(
|
|||
|
||||
val bootstrapJar =
|
||||
Option(Thread.currentThread().getContextClassLoader.getResourceAsStream("bootstrap.jar")) match {
|
||||
case Some(is) => Files.readFullySync(is)
|
||||
case Some(is) => Cache.readFullySync(is)
|
||||
case None =>
|
||||
Console.err.println(s"Error: bootstrap JAR not found")
|
||||
sys.exit(1)
|
||||
|
|
|
|||
|
|
@ -217,7 +217,7 @@ class Helper(
|
|||
logger.foreach(_.init())
|
||||
|
||||
val fetchs = cachePolicies.map(p =>
|
||||
Files.fetch(caches, p, logger = logger, pool = pool)
|
||||
Cache.fetch(caches, p, logger = logger, pool = pool)
|
||||
)
|
||||
val fetchQuiet = coursier.Fetch(
|
||||
repositories,
|
||||
|
|
@ -344,8 +344,8 @@ class Helper(
|
|||
None
|
||||
logger.foreach(_.init())
|
||||
val tasks = artifacts.map(artifact =>
|
||||
(Files.file(artifact, caches, cachePolicies.head, logger = logger, pool = pool) /: cachePolicies.tail)(
|
||||
_ orElse Files.file(artifact, caches, _, logger = logger, pool = pool)
|
||||
(Cache.file(artifact, caches, cachePolicies.head, logger = logger, pool = pool) /: cachePolicies.tail)(
|
||||
_ orElse Cache.file(artifact, caches, _, logger = logger, pool = pool)
|
||||
).run.map(artifact.->)
|
||||
)
|
||||
def printTask = Task {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import java.util.concurrent._
|
|||
|
||||
import ammonite.terminal.{ TTY, Ansi }
|
||||
|
||||
import coursier.Files.Logger
|
||||
import coursier.Cache
|
||||
|
||||
import scala.annotation.tailrec
|
||||
import scala.collection.mutable.ArrayBuffer
|
||||
|
|
@ -13,7 +13,7 @@ import scala.collection.mutable.ArrayBuffer
|
|||
class TermDisplay(
|
||||
out: Writer,
|
||||
var fallbackMode: Boolean = false
|
||||
) extends Logger {
|
||||
) extends Cache.Logger {
|
||||
|
||||
private val ansi = new Ansi(out)
|
||||
private var width = 80
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import scalaz.concurrent.{ Task, Strategy }
|
|||
|
||||
import java.io.{ Serializable => _, _ }
|
||||
|
||||
object Files {
|
||||
object Cache {
|
||||
|
||||
def withLocal(artifact: Artifact, cache: Seq[(String, File)]): Artifact = {
|
||||
def local(url: String) =
|
||||
|
|
@ -54,7 +54,7 @@ object Files {
|
|||
checksums: Set[String],
|
||||
cachePolicy: CachePolicy,
|
||||
pool: ExecutorService,
|
||||
logger: Option[Files.Logger] = None
|
||||
logger: Option[Logger] = None
|
||||
): Task[Seq[((File, String), FileError \/ Unit)]] = {
|
||||
|
||||
implicit val pool0 = pool
|
||||
|
|
@ -159,7 +159,7 @@ object Files {
|
|||
for (len <- Option(conn.getContentLengthLong).filter(_ >= 0L))
|
||||
logger.foreach(_.downloadLength(url, len))
|
||||
|
||||
val in = new BufferedInputStream(conn.getInputStream, Files.bufferSize)
|
||||
val in = new BufferedInputStream(conn.getInputStream, bufferSize)
|
||||
|
||||
val result =
|
||||
try {
|
||||
|
|
@ -172,7 +172,7 @@ object Files {
|
|||
if (lock == null)
|
||||
-\/(FileError.Locked(file))
|
||||
else {
|
||||
val b = Array.fill[Byte](Files.bufferSize)(0)
|
||||
val b = Array.fill[Byte](bufferSize)(0)
|
||||
|
||||
@tailrec
|
||||
def helper(count: Long): Unit = {
|
||||
|
|
@ -300,7 +300,7 @@ object Files {
|
|||
if (lock == null)
|
||||
-\/(FileError.Locked(f))
|
||||
else {
|
||||
Files.withContent(is, md.update(_, 0, _))
|
||||
withContent(is, md.update(_, 0, _))
|
||||
\/-(())
|
||||
}
|
||||
}
|
||||
|
|
@ -333,8 +333,8 @@ object Files {
|
|||
cache: Seq[(String, File)],
|
||||
cachePolicy: CachePolicy,
|
||||
checksums: Seq[Option[String]] = Seq(Some("SHA-1")),
|
||||
logger: Option[Files.Logger] = None,
|
||||
pool: ExecutorService = Files.defaultPool
|
||||
logger: Option[Logger] = None,
|
||||
pool: ExecutorService = defaultPool
|
||||
): EitherT[Task, FileError, File] = {
|
||||
|
||||
implicit val pool0 = pool
|
||||
|
|
@ -384,8 +384,8 @@ object Files {
|
|||
cache: Seq[(String, File)],
|
||||
cachePolicy: CachePolicy,
|
||||
checksums: Seq[Option[String]] = Seq(Some("SHA-1")),
|
||||
logger: Option[Files.Logger] = None,
|
||||
pool: ExecutorService = Files.defaultPool
|
||||
logger: Option[Logger] = None,
|
||||
pool: ExecutorService = defaultPool
|
||||
): Fetch.Content[Task] = {
|
||||
artifact =>
|
||||
file(
|
||||
|
|
@ -162,8 +162,8 @@ object Tasks {
|
|||
logger.foreach(_.init())
|
||||
val fetch = coursier.Fetch(
|
||||
repositories,
|
||||
Files.fetch(caches, CachePolicy.LocalOnly, checksums = checksums, logger = logger, pool = pool),
|
||||
Files.fetch(caches, cachePolicy, checksums = checksums, logger = logger, pool = pool)
|
||||
Cache.fetch(caches, CachePolicy.LocalOnly, checksums = checksums, logger = logger, pool = pool),
|
||||
Cache.fetch(caches, cachePolicy, checksums = checksums, logger = logger, pool = pool)
|
||||
)
|
||||
|
||||
def depsRepr = currentProject.dependencies.map { case (config, dep) =>
|
||||
|
|
@ -248,7 +248,7 @@ object Tasks {
|
|||
}
|
||||
|
||||
val artifactFileOrErrorTasks = allArtifacts.toVector.map { a =>
|
||||
Files.file(a, caches, cachePolicy, checksums = checksums, logger = logger, pool = pool).run.map((a, _))
|
||||
Cache.file(a, caches, cachePolicy, checksums = checksums, logger = logger, pool = pool).run.map((a, _))
|
||||
}
|
||||
|
||||
if (verbosity >= 0)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package coursier.test
|
||||
|
||||
import coursier.{ Module, Files }
|
||||
import coursier.{ Module, Cache }
|
||||
import utest._
|
||||
|
||||
object IvyLocalTests extends TestSuite {
|
||||
|
|
@ -10,7 +10,7 @@ object IvyLocalTests extends TestSuite {
|
|||
// Assume this module (and the sub-projects it depends on) is published locally
|
||||
CentralTests.resolutionCheck(
|
||||
Module("com.github.alexarchambault", "coursier_2.11"), "0.1.0-SNAPSHOT",
|
||||
Some(Files.ivy2Local))
|
||||
Some(Cache.ivy2Local))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue