diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2018-02-07 07:55:07 -0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2018-02-07 09:16:47 -0800 |
commit | e381552b992a5ba4743fa54f5111db9a2e9d98e2 (patch) | |
tree | 394b6eace1d4e30f42c0790f31ed0b25cdcd17e5 | |
parent | 3ba213bc51e33a54787d3a1e758384dff8052c1e (diff) | |
download | mill-e381552b992a5ba4743fa54f5111db9a2e9d98e2.tar.gz mill-e381552b992a5ba4743fa54f5111db9a2e9d98e2.tar.bz2 mill-e381552b992a5ba4743fa54f5111db9a2e9d98e2.zip |
attempt to fix publishAll
-rw-r--r-- | .travis.yml | 16 | ||||
-rwxr-xr-x | ci/release.py | 2 | ||||
-rw-r--r-- | core/src/mill/define/BaseModule.scala | 18 | ||||
-rw-r--r-- | core/src/mill/eval/Evaluator.scala | 2 | ||||
-rw-r--r-- | core/src/mill/main/ReplApplyHandler.scala | 2 | ||||
-rw-r--r-- | core/src/mill/main/Resolve.scala | 12 | ||||
-rw-r--r-- | core/src/mill/main/RunScript.scala | 25 | ||||
-rw-r--r-- | core/test/src/mill/define/CacherTests.scala | 2 | ||||
-rw-r--r-- | core/test/src/mill/eval/EvaluationTests.scala | 2 | ||||
-rw-r--r-- | core/test/src/mill/util/TestEvaluator.scala | 4 | ||||
-rw-r--r-- | core/test/src/mill/util/TestUtil.scala | 6 | ||||
-rw-r--r-- | scalajslib/test/src/mill/scalajslib/HelloJSWorldTests.scala | 2 | ||||
-rw-r--r-- | scalalib/src/mill/scalalib/PublishModule.scala | 1 | ||||
-rw-r--r-- | scalalib/test/src/mill/scalalib/HelloWorldTests.scala | 2 |
14 files changed, 60 insertions, 36 deletions
diff --git a/.travis.yml b/.travis.yml index 5621661f..8e93fd0b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,14 +10,14 @@ jdk: matrix: include: -# - stage: build -# env: CI_SCRIPT=ci/test-sbt.sh -# - stage: build -# env: CI_SCRIPT=ci/test-sbt-built.sh -# - stage: build -# env: CI_SCRIPT=ci/test-mill-built.sh -# - stage: build -# env: CI_SCRIPT=ci/test-mill-release.sh + - stage: build + env: CI_SCRIPT=ci/test-sbt.sh + - stage: build + env: CI_SCRIPT=ci/test-sbt-built.sh + - stage: build + env: CI_SCRIPT=ci/test-mill-built.sh + - stage: build + env: CI_SCRIPT=ci/test-mill-release.sh - stage: release env: CI_SCRIPT=ci/release.py diff --git a/ci/release.py b/ci/release.py index a385ba40..c08a1b17 100755 --- a/ci/release.py +++ b/ci/release.py @@ -21,5 +21,5 @@ check_call([ "mill.scalalib.PublishModule/publishAll", "lihaoyi:" + os.environ["SONATYPE_PASSWORD"], os.environ["GPG_PASSWORD"], - "_.publishArtifacts" + "__.publishArtifacts" ]) diff --git a/core/src/mill/define/BaseModule.scala b/core/src/mill/define/BaseModule.scala index 5b804658..12a01e89 100644 --- a/core/src/mill/define/BaseModule.scala +++ b/core/src/mill/define/BaseModule.scala @@ -31,12 +31,7 @@ abstract class BaseModule(millSourcePath0: Path, external0: Boolean = false) override implicit def millModuleBasePath: BasePath = BasePath(millSourcePath) implicit def millImplicitBaseModule: BaseModule.Implicit = BaseModule.Implicit(this) def millDiscover: Discover[this.type] -// implicit def millScoptModuleReads[T <: mill.Module] = new mill.main.ModuleScopt[T, this.type]( -// this, millDiscover -// ) - implicit def millScoptTargetReads[T] = new TargetScopt[T, this.type]( - this, millDiscover - ) + implicit def millScoptTargetReads[T] = new TargetScopt[T]() } @@ -55,10 +50,19 @@ abstract class ExternalModule(implicit millModuleEnclosing0: sourcecode.Enclosin } } -class TargetScopt[T, M <: BaseModule](rootModule: M, d: => Discover[M]) +object TargetScopt{ + // This needs to be a ThreadLocal because we need to pass it into the body of + // the TargetScopt#read call, which does not accept additional parameters. + // Until we migrate our CLI parsing off of Scopt (so we can pass the BaseModule + // in directly) we are forced to pass it in via a ThreadLocal + val currentRootModule = new ThreadLocal[BaseModule] +} +class TargetScopt[T]() extends scopt.Read[Seq[mill.define.Target[T]]]{ def arity = 1 def reads = s => try{ + val rootModule = TargetScopt.currentRootModule.get + val d = rootModule.millDiscover val (expanded, Nil) = ParseArgs(Seq(s)).fold(e => throw new Exception(e), identity) val resolved = expanded.map{ case (Some(scoping), segments) => diff --git a/core/src/mill/eval/Evaluator.scala b/core/src/mill/eval/Evaluator.scala index 4afbe233..fe43d0a3 100644 --- a/core/src/mill/eval/Evaluator.scala +++ b/core/src/mill/eval/Evaluator.scala @@ -27,7 +27,7 @@ case class Labelled[T](task: NamedTask[T], } class Evaluator[T](val outPath: Path, val externalOutPath: Path, - val rootModule: mill.Module, + val rootModule: mill.define.BaseModule, val discover: Discover[T], log: Logger, val classLoaderSig: Seq[(Path, Long)] = Evaluator.classLoaderSig){ diff --git a/core/src/mill/main/ReplApplyHandler.scala b/core/src/mill/main/ReplApplyHandler.scala index 5a84c344..0849f2c8 100644 --- a/core/src/mill/main/ReplApplyHandler.scala +++ b/core/src/mill/main/ReplApplyHandler.scala @@ -11,7 +11,7 @@ import scala.collection.mutable object ReplApplyHandler{ def apply[T](colors: ammonite.util.Colors, pprinter0: pprint.PPrinter, - rootModule: mill.Module, + rootModule: mill.define.BaseModule, discover: Discover[_]) = { new ReplApplyHandler( pprinter0, diff --git a/core/src/mill/main/Resolve.scala b/core/src/mill/main/Resolve.scala index 589f2c52..7ecd4ac8 100644 --- a/core/src/mill/main/Resolve.scala +++ b/core/src/mill/main/Resolve.scala @@ -14,7 +14,6 @@ object Resolve { remainingCrossSelectors: List[List[String]], revSelectorsSoFar: List[Segment]): Either[String, Seq[Task[Any]]] = { - pprint.log(remainingSelector) remainingSelector match{ case Segment.Cross(_) :: Nil => Left("Selector cannot start with a [cross] segment") case Segment.Label(last) :: Nil => @@ -70,7 +69,7 @@ object Resolve { val newRevSelectorsSoFar = head :: revSelectorsSoFar head match{ case Segment.Label(singleLabel) => - if (singleLabel == "_") { + if (singleLabel == "__") { val matching = obj.millInternal.modules @@ -79,6 +78,15 @@ object Resolve { if (matching.nonEmpty)Right(matching) else Left("Cannot resolve module " + Segments(newRevSelectorsSoFar.reverse:_*).render) + } else if (singleLabel == "_") { + + val matching = + obj.millModuleDirectChildren + .map(resolve(tail, _, discover, rest, remainingCrossSelectors, newRevSelectorsSoFar)) + .collect{case Right(vs) => vs}.flatten + + if (matching.nonEmpty)Right(matching) + else Left("Cannot resolve module " + Segments(newRevSelectorsSoFar.reverse:_*).render) }else{ obj.millInternal.reflectNestedObjects[mill.Module].find{ diff --git a/core/src/mill/main/RunScript.scala b/core/src/mill/main/RunScript.scala index fd969524..613d6441 100644 --- a/core/src/mill/main/RunScript.scala +++ b/core/src/mill/main/RunScript.scala @@ -76,7 +76,7 @@ object RunScript{ def evaluateMapping(wd: Path, path: Path, - interp: ammonite.interp.Interpreter): Res[(mill.Module, Discover[Any])] = { + interp: ammonite.interp.Interpreter): Res[(mill.define.BaseModule, Discover[Any])] = { val (pkg, wrapper) = Util.pathToPackageWrapper(Seq(), path relativeTo wd) @@ -107,7 +107,7 @@ object RunScript{ Res.Success( buildCls.getMethod("millSelf") .invoke(null) - .asInstanceOf[Some[mill.Module]] + .asInstanceOf[Some[mill.define.BaseModule]] .get ) } @@ -149,11 +149,22 @@ object RunScript{ case Segment.Cross(x) => x.toList.map(_.toString) case _ => Nil } - mill.main.Resolve.resolve( - sel.value.toList, rootModule, - discover, - args, crossSelectors.toList, Nil - ) + + try { + // We inject the `evaluator.rootModule` into the TargetScopt, rather + // than the `rootModule`, because even if you are running an external + // module we still want you to be able to resolve targets from your + // main build. Resolving targets from external builds as CLI arguments + // is not currently supported + mill.define.TargetScopt.currentRootModule.set(evaluator.rootModule) + mill.main.Resolve.resolve( + sel.value.toList, rootModule, + discover, + args, crossSelectors.toList, Nil + ) + } finally{ + mill.define.TargetScopt.currentRootModule.set(null) + } } EitherOps.sequence(selected) } diff --git a/core/test/src/mill/define/CacherTests.scala b/core/test/src/mill/define/CacherTests.scala index ce97202b..611db8c9 100644 --- a/core/test/src/mill/define/CacherTests.scala +++ b/core/test/src/mill/define/CacherTests.scala @@ -26,7 +26,7 @@ object CacherTests extends TestSuite{ } val tests = Tests{ - def eval[T <: TestUtil.TestBuild, V](mapping: T, v: Task[V]) + def eval[T <: TestUtil.BaseModule, V](mapping: T, v: Task[V]) (implicit discover: Discover[T], tp: TestPath) = { val evaluator = new TestEvaluator(mapping) evaluator(v).right.get._1 diff --git a/core/test/src/mill/eval/EvaluationTests.scala b/core/test/src/mill/eval/EvaluationTests.scala index 5b9936cb..9c4ace41 100644 --- a/core/test/src/mill/eval/EvaluationTests.scala +++ b/core/test/src/mill/eval/EvaluationTests.scala @@ -11,7 +11,7 @@ import utest.framework.TestPath import mill.util.TestEvaluator.implicitDisover import ammonite.ops._ object EvaluationTests extends TestSuite{ - class Checker[T <: TestUtil.TestBuild](module: T) + class Checker[T <: TestUtil.BaseModule](module: T) (implicit tp: TestPath, discover: Discover[T]) { // Make sure data is persisted even if we re-create the evaluator each time diff --git a/core/test/src/mill/util/TestEvaluator.scala b/core/test/src/mill/util/TestEvaluator.scala index c9230065..a5be0488 100644 --- a/core/test/src/mill/util/TestEvaluator.scala +++ b/core/test/src/mill/util/TestEvaluator.scala @@ -15,14 +15,14 @@ object TestEvaluator{ val externalOutPath = pwd / 'target / 'external - def static[T <: TestUtil.TestBuild](module: T) + def static[T <: TestUtil.BaseModule](module: T) (implicit discover: Discover[T], fullName: sourcecode.FullName) = { new TestEvaluator[T](module)(discover, fullName, TestPath(Nil)) } } -class TestEvaluator[T <: TestUtil.TestBuild](module: T) +class TestEvaluator[T <: TestUtil.BaseModule](module: T) (implicit discover: Discover[T], fullName: sourcecode.FullName, tp: TestPath){ diff --git a/core/test/src/mill/util/TestUtil.scala b/core/test/src/mill/util/TestUtil.scala index 93ea5ad8..9a5baf11 100644 --- a/core/test/src/mill/util/TestUtil.scala +++ b/core/test/src/mill/util/TestUtil.scala @@ -27,13 +27,13 @@ object TestUtil { pwd / 'target / 'worksources } - trait TestBuild extends mill.define.Module class BaseModule(implicit millModuleEnclosing0: sourcecode.Enclosing, millModuleLine0: sourcecode.Line, millName0: sourcecode.Name, overrides: Overrides) - extends mill.define.BaseModule(getSrcPathBase() / millModuleEnclosing0.value.split("\\.| |#")) - with TestBuild + extends mill.define.BaseModule(getSrcPathBase() / millModuleEnclosing0.value.split("\\.| |#")){ + def millDiscover: Discover[this.type] = Discover[this.type] + } object test{ diff --git a/scalajslib/test/src/mill/scalajslib/HelloJSWorldTests.scala b/scalajslib/test/src/mill/scalajslib/HelloJSWorldTests.scala index 16ba1fff..61e1671e 100644 --- a/scalajslib/test/src/mill/scalajslib/HelloJSWorldTests.scala +++ b/scalajslib/test/src/mill/scalajslib/HelloJSWorldTests.scala @@ -163,7 +163,7 @@ object HelloJSWorldTests extends TestSuite { def testArtifactId(scalaVersion: String, scalaJSVersion: String, artifactId: String): Unit = { - val Right((result, evalCount)) = helloWorldEvaluator(HelloJSWorld.helloJsWorld(scalaVersion, scalaJSVersion).artifact) + val Right((result, evalCount)) = helloWorldEvaluator(HelloJSWorld.helloJsWorld(scalaVersion, scalaJSVersion).artifactMetadata) assert(result.id == artifactId) } 'artifactId_0621 - testArtifactId("2.12.4", "0.6.22", "hello-js-world_sjs0.6_2.12") diff --git a/scalalib/src/mill/scalalib/PublishModule.scala b/scalalib/src/mill/scalalib/PublishModule.scala index 30fbb4c5..87a2f84f 100644 --- a/scalalib/src/mill/scalalib/PublishModule.scala +++ b/scalalib/src/mill/scalalib/PublishModule.scala @@ -104,5 +104,6 @@ object PublishModule extends ExternalModule{ x:_* ) } + millScoptTargetReads def millDiscover: mill.define.Discover[this.type] = mill.define.Discover[this.type] }
\ No newline at end of file diff --git a/scalalib/test/src/mill/scalalib/HelloWorldTests.scala b/scalalib/test/src/mill/scalalib/HelloWorldTests.scala index 24527cf1..1d39f180 100644 --- a/scalalib/test/src/mill/scalalib/HelloWorldTests.scala +++ b/scalalib/test/src/mill/scalalib/HelloWorldTests.scala @@ -113,7 +113,7 @@ object HelloWorldTests extends TestSuite { "Person$.class" ) - def workspaceTest[T, M <: TestUtil.TestBuild: Discover](m: M) + def workspaceTest[T, M <: TestUtil.BaseModule: Discover](m: M) (t: TestEvaluator[M] => T) (implicit tp: TestPath): T = { val eval = new TestEvaluator(m) |