summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorLi Haoyi <haoyi.sg@gmail.com>2019-05-19 15:15:24 +0800
committerGitHub <noreply@github.com>2019-05-19 15:15:24 +0800
commit68505aad4a22686594965bc910e60c8d2b6a95d4 (patch)
tree4c2099e21593a840c7119901becc0cbb8682956f /main
parent7d706641f6f9caa0509903f691d16d78402b4623 (diff)
downloadmill-68505aad4a22686594965bc910e60c8d2b6a95d4.tar.gz
mill-68505aad4a22686594965bc910e60c8d2b6a95d4.tar.bz2
mill-68505aad4a22686594965bc910e60c8d2b6a95d4.zip
Bump ammonite to 1.6.7 (#610)
* bump ammonite to 1.6.7 * upgrade all the things * add scalaj-http shims for bootstrapping * wip * tweak-error-message * tweak coursier * .
Diffstat (limited to 'main')
-rw-r--r--main/core/src/eval/Evaluator.scala4
-rw-r--r--main/core/src/util/JsonFormatters.scala5
-rw-r--r--main/src/main/MainRunner.scala2
-rw-r--r--main/src/main/VisualizeModule.scala4
-rw-r--r--main/src/modules/Jvm.scala43
-rw-r--r--main/src/modules/Util.scala2
6 files changed, 36 insertions, 24 deletions
diff --git a/main/core/src/eval/Evaluator.scala b/main/core/src/eval/Evaluator.scala
index ebb00ef1..f4ec8ff9 100644
--- a/main/core/src/eval/Evaluator.scala
+++ b/main/core/src/eval/Evaluator.scala
@@ -32,7 +32,7 @@ case class Evaluator(home: os.Path,
externalOutPath: os.Path,
rootModule: mill.define.BaseModule,
log: Logger,
- classLoaderSig: Seq[(Either[String, os.Path], Long)] = Evaluator.classLoaderSig,
+ classLoaderSig: Seq[(Either[String, java.net.URL], Long)] = Evaluator.classLoaderSig,
workerCache: mutable.Map[Segments, (Int, Any)] = mutable.Map.empty,
env : Map[String, String] = Evaluator.defaultEnv,
failFast: Boolean = true
@@ -374,7 +374,7 @@ object Evaluator{
implicit val rw: upickle.default.ReadWriter[Cached] = upickle.default.macroRW
}
case class State(rootModule: mill.define.BaseModule,
- classLoaderSig: Seq[(Either[String, os.Path], Long)],
+ classLoaderSig: Seq[(Either[String, java.net.URL], Long)],
workerCache: mutable.Map[Segments, (Int, Any)],
watched: Seq[(os.Path, Long)])
// This needs to be a ThreadLocal because we need to pass it into the body of
diff --git a/main/core/src/util/JsonFormatters.scala b/main/core/src/util/JsonFormatters.scala
index 830782c6..c1dd18f0 100644
--- a/main/core/src/util/JsonFormatters.scala
+++ b/main/core/src/util/JsonFormatters.scala
@@ -6,5 +6,10 @@ trait JsonFormatters extends mill.api.JsonFormatters{
implicit lazy val modFormat: RW[coursier.Module] = upickle.default.macroRW
implicit lazy val depFormat: RW[coursier.Dependency]= upickle.default.macroRW
implicit lazy val attrFormat: RW[coursier.Attributes] = upickle.default.macroRW
+ implicit lazy val orgFormat: RW[coursier.Organization] = upickle.default.macroRW
+ implicit lazy val modNameFormat: RW[coursier.ModuleName] = upickle.default.macroRW
+ implicit lazy val configurationFormat: RW[coursier.core.Configuration] = upickle.default.macroRW
+ implicit lazy val typeFormat: RW[coursier.core.Type] = upickle.default.macroRW
+ implicit lazy val classifierFormat: RW[coursier.core.Classifier] = upickle.default.macroRW
}
object JsonFormatters extends JsonFormatters
diff --git a/main/src/main/MainRunner.scala b/main/src/main/MainRunner.scala
index c773087c..6705a4b3 100644
--- a/main/src/main/MainRunner.scala
+++ b/main/src/main/MainRunner.scala
@@ -128,7 +128,7 @@ class MainRunner(val config: ammonite.main.Cli.Config,
)
}
- object CustomCodeWrapper extends Preprocessor.CodeWrapper {
+ object CustomCodeWrapper extends ammonite.interp.CodeWrapper {
def apply(code: String,
source: CodeSource,
imports: ammonite.util.Imports,
diff --git a/main/src/main/VisualizeModule.scala b/main/src/main/VisualizeModule.scala
index e950973f..b3d59509 100644
--- a/main/src/main/VisualizeModule.scala
+++ b/main/src/main/VisualizeModule.scala
@@ -2,7 +2,7 @@ package mill.main
import java.util.concurrent.LinkedBlockingQueue
-import coursier.Cache
+import coursier.LocalRepositories
import coursier.core.Repository
import coursier.maven.MavenRepository
import mill.T
@@ -11,7 +11,7 @@ import mill.eval.{PathRef, Result}
object VisualizeModule extends ExternalModule with VisualizeModule {
def repositories = Seq(
- Cache.ivy2Local,
+ LocalRepositories.ivy2Local,
MavenRepository("https://repo1.maven.org/maven2"),
MavenRepository("https://oss.sonatype.org/content/repositories/releases")
)
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()
diff --git a/main/src/modules/Util.scala b/main/src/modules/Util.scala
index 20f06d8f..8cb72e61 100644
--- a/main/src/modules/Util.scala
+++ b/main/src/modules/Util.scala
@@ -65,7 +65,7 @@ object Util {
repositories,
Seq(
coursier.Dependency(
- coursier.Module("com.lihaoyi", artifact + artifactSuffix),
+ coursier.Module(coursier.Organization("com.lihaoyi"), coursier.ModuleName(artifact + artifactSuffix)),
sys.props("MILL_VERSION")
)
),