diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2018-01-14 05:14:28 -0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2018-01-14 05:22:37 -0800 |
commit | 16d98bbbf1a29a00c06e694a4eeb088842380c2c (patch) | |
tree | 3962395b144bcbeb94462800a1c5fb8c38cc0fa8 /core/src/main/scala | |
parent | de96a55c3267bb1508e77a6815007807e3fd73fb (diff) | |
download | mill-16d98bbbf1a29a00c06e694a4eeb088842380c2c.tar.gz mill-16d98bbbf1a29a00c06e694a4eeb088842380c2c.tar.bz2 mill-16d98bbbf1a29a00c06e694a4eeb088842380c2c.zip |
more work to get tests passing...
Diffstat (limited to 'core/src/main/scala')
-rw-r--r-- | core/src/main/scala/mill/define/Discover.scala | 14 | ||||
-rw-r--r-- | core/src/main/scala/mill/define/Module.scala | 1 | ||||
-rw-r--r-- | core/src/main/scala/mill/main/Resolve.scala | 19 |
3 files changed, 25 insertions, 9 deletions
diff --git a/core/src/main/scala/mill/define/Discover.scala b/core/src/main/scala/mill/define/Discover.scala index 0db2d617..52f4ab77 100644 --- a/core/src/main/scala/mill/define/Discover.scala +++ b/core/src/main/scala/mill/define/Discover.scala @@ -11,6 +11,7 @@ object Discover { def applyImpl[T: c.WeakTypeTag](c: blackbox.Context): c.Expr[Discover] = { import c.universe._ + import compat._ val seen = mutable.Set.empty[Type] def rec(tpe: Type): Unit = { if (!seen(tpe)){ @@ -20,6 +21,19 @@ object Discover { memberTpe = m.typeSignature if memberTpe.resultType <:< typeOf[mill.define.Module] && memberTpe.paramLists.isEmpty } rec(memberTpe.resultType) + + if (tpe <:< typeOf[mill.define.Cross[_]]){ + val inner = typeOf[Cross[_]] + .typeSymbol + .asClass + .typeParams + .head + .asType + .toType + .asSeenFrom(tpe, typeOf[Cross[_]].typeSymbol) + + rec(inner) + } } } rec(weakTypeOf[T]) diff --git a/core/src/main/scala/mill/define/Module.scala b/core/src/main/scala/mill/define/Module.scala index 4634b9a3..77bc7e36 100644 --- a/core/src/main/scala/mill/define/Module.scala +++ b/core/src/main/scala/mill/define/Module.scala @@ -52,6 +52,7 @@ class Module(implicit ctx0: mill.define.Ctx) extends mill.moduledefs.Cacher{ this .getClass .getMethods + .filter(!_.getName.contains('$')) .filter(_.getParameterCount == 0) .filter(x => (x.getModifiers & Modifier.STATIC) == 0) .filter(implicitly[ClassTag[T]].runtimeClass isAssignableFrom _.getReturnType) diff --git a/core/src/main/scala/mill/main/Resolve.scala b/core/src/main/scala/mill/main/Resolve.scala index df3c250d..aedcc619 100644 --- a/core/src/main/scala/mill/main/Resolve.scala +++ b/core/src/main/scala/mill/main/Resolve.scala @@ -16,21 +16,22 @@ object Resolve { remainingSelector match{ case Segment.Cross(_) :: Nil => Left("Selector cannot start with a [cross] segment") case Segment.Label(last) :: Nil => - def target = + val target = obj .reflect[Target[_]] .find(_.label == last) .map(Right(_)) - def invokeCommand[V](target: mill.Module, name: String) = for{ - cmd <- discover.value.get(target.getClass).toSeq.flatten.find(_.name == name) - } yield cmd.asInstanceOf[EntryPoint[mill.Module]].invoke(target, ammonite.main.Scripts.groupArgs(rest.toList)) match { - case Router.Result.Success(v) => Right(v) - case _ => Left(s"Command failed $last") + def invokeCommand[V](target: mill.Module, name: String) = { + for(cmd <- discover.value.get(target.getClass).toSeq.flatten.find(_.name == name)) + yield cmd.asInstanceOf[EntryPoint[mill.Module]].invoke(target, ammonite.main.Scripts.groupArgs(rest.toList)) match { + case Router.Result.Success(v) => Right(v) + case _ => Left(s"Command failed $last") + } } - def runDefault = for{ - child <- obj.reflect[mill.Module] + val runDefault = for{ + child <- obj.reflectNestedObjects[mill.Module] if child.ctx.segment == Segment.Label(last) res <- child match{ case taskMod: TaskModule => Some(invokeCommand(child, taskMod.defaultCommandName())) @@ -38,7 +39,7 @@ object Resolve { } } yield res - def command = invokeCommand(obj, last) + val command = invokeCommand(obj, last) command orElse target orElse runDefault.headOption.flatten match{ case None => Left("Cannot resolve task " + |