diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2018-01-17 23:44:01 -0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2018-01-17 23:44:01 -0800 |
commit | 1341e29629ec633a8d9db0e1717434ab560aab42 (patch) | |
tree | b70ce24feef8ddb7e009a1521e2ca14868a7a5da /core/src | |
parent | 26e3702f3fccdedbb9dd44574678e9217d16959c (diff) | |
download | mill-1341e29629ec633a8d9db0e1717434ab560aab42.tar.gz mill-1341e29629ec633a8d9db0e1717434ab560aab42.tar.bz2 mill-1341e29629ec633a8d9db0e1717434ab560aab42.zip |
Introduce an Ammonite build to our test suite
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/main/scala/mill/define/Cross.scala | 5 | ||||
-rw-r--r-- | core/src/main/scala/mill/define/Ctx.scala | 30 | ||||
-rw-r--r-- | core/src/main/scala/mill/define/Module.scala | 5 | ||||
-rw-r--r-- | core/src/main/scala/mill/main/MainRunner.scala | 3 |
4 files changed, 21 insertions, 22 deletions
diff --git a/core/src/main/scala/mill/define/Cross.scala b/core/src/main/scala/mill/define/Cross.scala index 0d799f19..b51064be 100644 --- a/core/src/main/scala/mill/define/Cross.scala +++ b/core/src/main/scala/mill/define/Cross.scala @@ -56,10 +56,7 @@ class Cross[T](cases: Any*) case v => Tuple1(v) } val crossValues = c.productIterator.toList - val relPath = ctx.segment match{ - case Segment.Label(s) => ammonite.ops.empty / s - case Segment.Cross(vs) => ammonite.ops.empty / vs.map(_.toString) - } + val relPath = ctx.segment.pathSegments val sub = ci.make( c, ctx.copy( diff --git a/core/src/main/scala/mill/define/Ctx.scala b/core/src/main/scala/mill/define/Ctx.scala index 308c50ef..6d685521 100644 --- a/core/src/main/scala/mill/define/Ctx.scala +++ b/core/src/main/scala/mill/define/Ctx.scala @@ -1,11 +1,16 @@ package mill.define import ammonite.main.Router.Overrides -import ammonite.ops.Path +import ammonite.ops.{Path, RelPath} import scala.annotation.implicitNotFound -sealed trait Segment +sealed trait Segment{ + def pathSegments: Seq[String] = this match{ + case Segment.Label(s) => List(s) + case Segment.Cross(vs) => vs.map(_.toString) + } +} object Segment{ case class Label(value: String) extends Segment case class Cross(value: Seq[Any]) extends Segment @@ -42,7 +47,8 @@ case class Ctx(enclosing: String, segment: Segment, basePath: Path, segments: Segments, - overrides: Int) + overrides: Int){ +} object Ctx{ implicit def make(implicit millModuleEnclosing0: sourcecode.Enclosing, @@ -50,12 +56,14 @@ object Ctx{ millName0: sourcecode.Name, millModuleBasePath0: BasePath, segments0: Segments, - overrides0: Overrides): Ctx = Ctx( - millModuleEnclosing0.value, - millModuleLine0.value, - Segment.Label(millName0.value), - millModuleBasePath0.value, - segments0, - overrides0.value - ) + overrides0: Overrides): Ctx = { + Ctx( + millModuleEnclosing0.value, + millModuleLine0.value, + Segment.Label(millName0.value), + millModuleBasePath0.value, + segments0, + overrides0.value + ) + } }
\ No newline at end of file diff --git a/core/src/main/scala/mill/define/Module.scala b/core/src/main/scala/mill/define/Module.scala index f7c84b6d..e42ce798 100644 --- a/core/src/main/scala/mill/define/Module.scala +++ b/core/src/main/scala/mill/define/Module.scala @@ -24,10 +24,7 @@ class Module(implicit outerCtx0: mill.define.Ctx) extends mill.moduledefs.Cacher lazy val millModuleDirectChildren = millInternal.reflectNestedObjects[Module] def millOuterCtx = outerCtx0 - def basePath: Path = millOuterCtx.basePath / (millOuterCtx.segment match{ - case Segment.Label(s) => List(s) - case Segment.Cross(vs) => vs.map(_.toString) - }) + def basePath: Path = millOuterCtx.basePath / millOuterCtx.segment.pathSegments implicit def millModuleBasePath: BasePath = BasePath(basePath) implicit def millModuleSegments: Segments = { millOuterCtx.segments ++ Seq(millOuterCtx.segment) diff --git a/core/src/main/scala/mill/main/MainRunner.scala b/core/src/main/scala/mill/main/MainRunner.scala index 70cc350c..5281b886 100644 --- a/core/src/main/scala/mill/main/MainRunner.scala +++ b/core/src/main/scala/mill/main/MainRunner.scala @@ -91,9 +91,6 @@ class MainRunner(config: ammonite.main.Cli.Config, |import mill._ | |object $wrapName extends mill.define.BaseModule(ammonite.ops.Path(${pprint.Util.literalize(config.wd.toString)})) with $wrapName{ - | // Make sure we don't include the `build` wrapper-object's name in - | // the `basePath`s of our build - | override def basePath = super.basePath / ammonite.ops.up | // Stub to make sure Ammonite has something to call after it evaluates a script, | // even if it does nothing... | def $$main() = Iterator[String]() |