From 2d7241efab9ad4589b1a7db8353607a417ab1567 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Tue, 26 Dec 2017 00:42:45 -0800 Subject: - Shift `MappingCtx` into a magic `LoaderCtx` `Loader` to avoid circular dependencies between `Ctx` -> `Discovered` -> `Task` - `mill idea` works now using `GenIdea` as a standalone `T.command` making use of the new contextually-available `Mapping` - Limit implicit `ReplApplyHandler` to `--repl` only, to avoid it kicking in if `build.sc` scripts are screwed up and adding further confusion --- scalaplugin/src/main/scala/mill/scalaplugin/GenIdea.scala | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'scalaplugin/src') diff --git a/scalaplugin/src/main/scala/mill/scalaplugin/GenIdea.scala b/scalaplugin/src/main/scala/mill/scalaplugin/GenIdea.scala index 86e33d8d..c7ea448a 100644 --- a/scalaplugin/src/main/scala/mill/scalaplugin/GenIdea.scala +++ b/scalaplugin/src/main/scala/mill/scalaplugin/GenIdea.scala @@ -5,11 +5,13 @@ import mill.define.Target import mill.discover.Mirror.{LabelledTarget, Segment} import mill.discover.{Discovered, Mirror} import mill.eval.{Evaluator, PathRef} +import mill.util.Ctx.LoaderCtx import mill.util.{OSet, PrintLogger} object GenIdea { - def apply[T](mapping: Discovered.Mapping[T]): Unit = { + def apply()(implicit ctx: LoaderCtx): Unit = { + val mapping = ctx.load(mill.discover.Discovered.Mapping) val pp = new scala.xml.PrettyPrinter(999, 4) rm! pwd/".idea" rm! pwd/".idea_modules" @@ -18,13 +20,12 @@ object GenIdea { val evaluator = new Evaluator(workspacePath, mapping, new PrintLogger(true)) - for((relPath, xml) <- xmlFileLayout(mapping, evaluator)){ + for((relPath, xml) <- xmlFileLayout(evaluator)){ write.over(pwd/relPath, pp.format(xml)) } } - def xmlFileLayout[T](evaluator: Evaluator): Seq[(RelPath, scala.xml.Node)] = { - + def xmlFileLayout[T](evaluator: Evaluator[T]): Seq[(RelPath, scala.xml.Node)] = { val modules = Mirror .traverse(evaluator.mapping.base, evaluator.mapping.mirror){ (h, p) => @@ -77,7 +78,10 @@ object GenIdea { val Seq(sourcePath: PathRef) = evaluator.evaluate(OSet(mod.sources)).values - val (destPath, jsonPath) = evaluator.resolveDestPaths(mapping.value(mod.compile)) + val (destPath, jsonPath) = Evaluator.resolveDestPaths( + evaluator.workspacePath, + evaluator.mapping.value(mod.compile) + ) val elem = moduleXmlTemplate( sourcePath.path, -- cgit v1.2.3