diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2018-01-06 23:25:29 -0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2018-01-07 00:21:37 -0800 |
commit | 7cd18fd936b95410274be031a8231e5a3d9866a4 (patch) | |
tree | c3d9a1f4a110dc5f25824eb9f118ea8ebfcd2b37 /integration/src/test | |
parent | a6febe05a5650274110301a09bb97e4770ea0400 (diff) | |
download | mill-7cd18fd936b95410274be031a8231e5a3d9866a4.tar.gz mill-7cd18fd936b95410274be031a8231e5a3d9866a4.tar.bz2 mill-7cd18fd936b95410274be031a8231e5a3d9866a4.zip |
First pass at implicitly propagating a `def basePath: Path` up the `Module` hierarchy, which each module receives and extends.
One constraint is that now must define your abstract modules as `trait`s rather than `class`es, or otherwise add an implicit `ctx: ModuleCtx` parameter to your class definition.
So far this lets us remove some explicit `basePath` definitions in `build.sc`. Proper handling of `basePath` in `CrossModule`s is future work
Diffstat (limited to 'integration/src/test')
4 files changed, 25 insertions, 28 deletions
diff --git a/integration/src/test/resource/acyclic/build.sc b/integration/src/test/resource/acyclic/build.sc index ec338e9f..f1381c7e 100644 --- a/integration/src/test/resource/acyclic/build.sc +++ b/integration/src/test/resource/acyclic/build.sc @@ -5,7 +5,7 @@ import mill.scalalib.publish.{PomSettings, License, Developer, SCM} object acyclic extends CrossModule(AcyclicModule, "2.10.6", "2.11.8", "2.12.3", "2.12.4") case class AcyclicModule(crossVersion: String) extends SbtModule with PublishModule { - def basePath = ammonite.ops.pwd / 'target / 'workspace / 'acyclic + def basePath = super.basePath / ammonite.ops.up def artifactName = "acyclic" def publishVersion = "0.1.7" diff --git a/integration/src/test/resource/better-files/build.sc b/integration/src/test/resource/better-files/build.sc index bfb7f89c..ace8f766 100644 --- a/integration/src/test/resource/better-files/build.sc +++ b/integration/src/test/resource/better-files/build.sc @@ -61,25 +61,20 @@ trait BetterFilesModule extends SbtModule{ } } -object core extends BetterFilesModule{ - def basePath = ammonite.ops.pwd / 'target / 'workspace / "better-files" / 'core -} +object core extends BetterFilesModule object akka extends BetterFilesModule{ def projectDeps = Seq(core) - def basePath = ammonite.ops.pwd / 'target / 'workspace / "better-files" / 'akka def ivyDeps = Seq(Dep("com.typesafe.akka", "akka-actor", "2.5.6")) } -object shapelessScanner extends BetterFilesModule{ +object shapeless extends BetterFilesModule{ def projectDeps = Seq(core) - def basePath = ammonite.ops.pwd / 'target / 'workspace / "better-files" / 'shapeless def ivyDeps = Seq(Dep("com.chuusai", "shapeless", "2.3.2")) } object benchmarks extends BetterFilesModule{ def projectDeps = Seq(core) - def basePath = ammonite.ops.pwd / 'target / 'workspace / "better-files" / 'benchmarks def ivyDeps = Seq( Dep.Java("commons-io", "commons-io", "2.5") // "fastjavaio" % "fastjavaio" % "1.0" from "https://github.com/williamfiset/FastJavaIO/releases/download/v1.0/fastjavaio.jar" diff --git a/integration/src/test/resource/jawn/build.sc b/integration/src/test/resource/jawn/build.sc index 75dfeaa1..074e30f9 100644 --- a/integration/src/test/resource/jawn/build.sc +++ b/integration/src/test/resource/jawn/build.sc @@ -4,6 +4,8 @@ import mill.scalalib.{Dep, TestModule, Module} object jawn extends CrossModule(JawnModule, "2.10.6", "2.11.11", "2.12.3") case class JawnModule(crossVersion: String) extends mill.Module{ + override def basePath = super.basePath / ammonite.ops.up + trait JawnModule extends scalalib.SbtModule{ def scalaVersion = crossVersion def scalacOptions = Seq( @@ -21,38 +23,38 @@ case class JawnModule(crossVersion: String) extends mill.Module{ def testFramework = "org.scalatest.tools.Framework" } } - object parser extends JawnModule{ - def basePath = ammonite.ops.pwd / 'target / 'workspace / 'jawn / 'parser - } + object parser extends JawnModule + object util extends JawnModule{ def projectDeps = Seq(parser) def testProjectDeps = Seq(parser.test) - def basePath = ammonite.ops.pwd / 'target / 'workspace / 'jawn / 'util } object ast extends JawnModule{ def projectDeps = Seq(parser, util) def testProjectDeps = Seq(parser.test, util.test) - def basePath = ammonite.ops.pwd / 'target / 'workspace / 'jawn / 'ast } - class Support(name: String, ivyDeps0: Dep*) extends JawnModule{ + class Support(ivyDeps0: Dep*)(implicit ctx: mill.Module.Ctx) extends JawnModule{ def projectDeps = Seq[Module](parser) - def basePath = ammonite.ops.pwd / 'target / 'workspace / 'jawn / 'support / name def ivyDeps = ivyDeps0 } - object argonaut extends Support("argonaut", Dep("io.argonaut", "argonaut", "6.2")) - object json4s extends Support("json4s", Dep("org.json4s", "json4s-ast", "3.5.2")) + object support extends mill.Module{ + object argonaut extends Support(Dep("io.argonaut", "argonaut", "6.2")) + object json4s extends Support(Dep("org.json4s", "json4s-ast", "3.5.2")) - object play extends Support("play"){ - def ivyDeps = mill.T{ - scalaBinaryVersion() match{ - case "2.10" => Seq(Dep("com.typesafe.play", "play-json", "2.4.11")) - case "2.11" => Seq(Dep("com.typesafe.play", "play-json", "2.5.15")) - case _ => Seq(Dep("com.typesafe.play", "play-json", "2.6.0")) + object play extends Support(){ + def ivyDeps = mill.T{ + scalaBinaryVersion() match{ + case "2.10" => Seq(Dep("com.typesafe.play", "play-json", "2.4.11")) + case "2.11" => Seq(Dep("com.typesafe.play", "play-json", "2.5.15")) + case _ => Seq(Dep("com.typesafe.play", "play-json", "2.6.0")) + } } } - } - object rojoma extends Support("rojoma", Dep("com.rojoma", "rojoma-json", "2.4.3")) - object rojomaV3 extends Support("rojoma-v3", Dep("com.rojoma", "rojoma-json-v3", "3.7.2")) - object spray extends Support("spray", Dep("io.spray", "spray-json", "1.3.3")) + object rojoma extends Support(Dep("com.rojoma", "rojoma-json", "2.4.3")) + object rojomaV3 extends Support(Dep("com.rojoma", "rojoma-json-v3", "3.7.2")){ + override def basePath = super.basePath / ammonite.ops.up / "rojoma-v3" + } + object spray extends Support(Dep("io.spray", "spray-json", "1.3.3")) + } }
\ No newline at end of file diff --git a/integration/src/test/scala/mill/integration/IntegrationTestSuite.scala b/integration/src/test/scala/mill/integration/IntegrationTestSuite.scala index 2c595e35..b7dc722d 100644 --- a/integration/src/test/scala/mill/integration/IntegrationTestSuite.scala +++ b/integration/src/test/scala/mill/integration/IntegrationTestSuite.scala @@ -12,7 +12,7 @@ abstract class IntegrationTestSuite(repoKey: String, workspaceSlug: String) exte val stdIn = new ByteArrayInputStream(Array()) val runner = new mill.main.MainRunner( ammonite.main.Cli.Config(wd = workspacePath), false, - System.out, System.err, System.in + stdOutErr, stdOutErr, stdIn ) def eval(s: String*) = runner.runScript(workspacePath / "build.sc", s.toList) def meta(s: String) = read(workspacePath / "out" / RelPath(s.replaceAll("\\.", "/")) / "meta.json") |