summaryrefslogtreecommitdiff
path: root/main/src/modules/Jvm.scala
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/modules/Jvm.scala')
-rw-r--r--main/src/modules/Jvm.scala43
1 files changed, 25 insertions, 18 deletions
diff --git a/main/src/modules/Jvm.scala b/main/src/modules/Jvm.scala
index 9ee51aea..9f176974 100644
--- a/main/src/modules/Jvm.scala
+++ b/main/src/modules/Jvm.scala
@@ -8,7 +8,7 @@ import java.nio.file.attribute.PosixFilePermission
import java.util.Collections
import java.util.jar.{JarEntry, JarFile, JarOutputStream}
-import coursier.{Cache, Dependency, Fetch, Repository, Resolution, CachePolicy}
+import coursier.{Dependency, Fetch, Repository, Resolution}
import coursier.util.{Gather, Task}
import geny.Generator
import mill.main.client.InputPumper
@@ -37,7 +37,7 @@ object Jvm {
val commandArgs =
Vector("java") ++
jvmArgs ++
- Vector("-cp", classPath.mkString(File.pathSeparator), mainClass) ++
+ Vector("-cp", classPath.mkString(java.io.File.pathSeparator), mainClass) ++
mainArgs
val workingDir1 = Option(workingDir).getOrElse(ctx.dest)
@@ -60,7 +60,7 @@ object Jvm {
val args =
Vector("java") ++
jvmArgs ++
- Vector("-cp", classPath.mkString(File.pathSeparator), mainClass) ++
+ Vector("-cp", classPath.mkString(java.io.File.pathSeparator), mainClass) ++
mainArgs
if (background) spawnSubprocess(args, envArgs, workingDir)
@@ -409,6 +409,7 @@ object Jvm {
repositories, deps, force, mapDependencies, ctx
)
val errs = resolution.metadataErrors
+
if(errs.nonEmpty) {
val header =
s"""|
@@ -424,13 +425,11 @@ object Jvm {
} else {
def load(artifacts: Seq[coursier.Artifact]) = {
- val logger = None
import scala.concurrent.ExecutionContext.Implicits.global
val loadedArtifacts = Gather[Task].gather(
for (a <- artifacts)
- yield coursier.Cache.file[Task](a, logger = logger).run
- .map(a.isOptional -> _)
+ yield coursier.cache.Cache.default.file(a).run.map(a.optional -> _)
).unsafeRun
val errors = loadedArtifacts.collect {
@@ -442,8 +441,13 @@ object Jvm {
}
val sourceOrJar =
- if (sources) resolution.classifiersArtifacts(Seq("sources"))
- else resolution.artifacts(true)
+ if (sources) {
+ resolution.artifacts(
+ types = Set(coursier.Type.source, coursier.Type.javaSource),
+ classifiers = Some(Seq(coursier.Classifier("sources")))
+ )
+ }
+ else resolution.artifacts()
val (errors, successes) = load(sourceOrJar)
if(errors.isEmpty){
mill.Agg.from(
@@ -463,7 +467,7 @@ object Jvm {
mapDependencies: Option[Dependency => Dependency] = None,
ctx: Option[mill.util.Ctx.Log] = None) = {
- val cachePolicies = CachePolicy.default
+ val cachePolicies = coursier.cache.CacheDefaults.cachePolicies
val forceVersions = force
.map(mapDependencies.getOrElse(identity[Dependency](_)))
@@ -471,20 +475,23 @@ object Jvm {
.toMap
val start = Resolution(
- deps.map(mapDependencies.getOrElse(identity[Dependency](_))).toSet,
+ deps.map(mapDependencies.getOrElse(identity[Dependency](_))).toSeq,
forceVersions = forceVersions,
mapDependencies = mapDependencies
)
val resolutionLogger = ctx.map(c => new TickerResolutionLogger(c))
- val fetches = cachePolicies.map { p =>
- Cache.fetch[Task](
- logger = resolutionLogger,
- cachePolicy = p
- )
+ val cache = resolutionLogger match {
+ case None => coursier.cache.FileCache[Task].withCachePolicies(cachePolicies)
+ case Some(l) =>
+ coursier.cache.FileCache[Task]
+ .withCachePolicies(cachePolicies)
+ .withLogger(l)
}
- val fetch = Fetch.from(repositories, fetches.head, fetches.tail: _*)
+ val fetches = cache.fetchs
+
+ val fetch = coursier.core.ResolutionProcess.fetch(repositories, fetches.head, fetches.tail: _*)
import scala.concurrent.ExecutionContext.Implicits.global
val resolution = start.process.run(fetch).unsafeRun()
@@ -498,7 +505,7 @@ object Jvm {
* In practice, this ticker output gets prefixed with the current target for which
* dependencies are being resolved, using a [[mill.util.ProxyLogger]] subclass.
*/
- class TickerResolutionLogger(ctx: mill.util.Ctx.Log) extends Cache.Logger {
+ class TickerResolutionLogger(ctx: mill.util.Ctx.Log) extends coursier.cache.CacheLogger {
case class DownloadState(var current: Long, var total: Long)
var downloads = new mutable.TreeMap[String,DownloadState]()
var totalDownloadCount = 0
@@ -518,7 +525,7 @@ object Jvm {
ctx.log.ticker(s"Downloading [${downloads.size + finishedCount}/$totalDownloadCount] artifacts (~${sums.current}/${sums.total} bytes)")
}
- override def downloadingArtifact(url: String, file: File): Unit = synchronized {
+ override def downloadingArtifact(url: String): Unit = synchronized {
totalDownloadCount += 1
downloads += url -> DownloadState(0,0)
updateTicker()