From 60f0a0ae5098b28999c279f0cdb105921b2c113a Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Sun, 28 Jan 2018 00:07:12 -0800 Subject: Fix gen idea tests --- scalalib/src/mill/scalalib/GenIdea.scala | 32 ++++++++++++---------- scalalib/test/src/mill/scalalib/GenIdeaTests.scala | 6 ++-- 2 files changed, 21 insertions(+), 17 deletions(-) (limited to 'scalalib') diff --git a/scalalib/src/mill/scalalib/GenIdea.scala b/scalalib/src/mill/scalalib/GenIdea.scala index 7fa2536d..c48e3bc8 100644 --- a/scalalib/src/mill/scalalib/GenIdea.scala +++ b/scalalib/src/mill/scalalib/GenIdea.scala @@ -28,25 +28,29 @@ object GenIdea { } } - def xmlFileLayout[T](evaluator: Evaluator[T], rootModule: mill.Module): Seq[(RelPath, scala.xml.Node)] = { + def xmlFileLayout[T](evaluator: Evaluator[T], + rootModule: mill.Module, + fetchMillModules: Boolean = true): Seq[(RelPath, scala.xml.Node)] = { val modules = rootModule.millInternal.segmentsToModules.values .collect{ case x: scalalib.ScalaModule => (x.millModuleSegments, x)} .toSeq - val buildLibraryPaths = sys.props.get("MILL_BUILD_LIBRARIES") match { - case Some(found) => Agg.from(found.split(',').map(Path(_)).distinct) - case None => - val artifactNames = Seq("moduledefs", "core", "scalalib", "scalajslib") - val Result.Success(res) = scalalib.Lib.resolveDependencies( - Seq(Cache.ivy2Local, MavenRepository("https://repo1.maven.org/maven2")), - "2.12.4", - "2.12", - for(name <- artifactNames) - yield Dep("com.lihaoyi", s"mill-${name}", "0.0.1-SNAPSHOT") - ) - res.items.toSeq.map(_.path) - } + val buildLibraryPaths = + if (!fetchMillModules) Nil + else sys.props.get("MILL_BUILD_LIBRARIES") match { + case Some(found) => Agg.from(found.split(',').map(Path(_)).distinct) + case None => + val artifactNames = Seq("moduledefs", "core", "scalalib", "scalajslib") + val Result.Success(res) = scalalib.Lib.resolveDependencies( + Seq(Cache.ivy2Local, MavenRepository("https://repo1.maven.org/maven2")), + "2.12.4", + "2.12", + for(name <- artifactNames) + yield Dep("com.lihaoyi", s"mill-${name}", "0.0.1-SNAPSHOT") + ) + res.items.toSeq.map(_.path) + } val resolved = for((path, mod) <- modules) yield { val Seq(resolvedCp: Loose.Agg[PathRef], resolvedSrcs: Loose.Agg[PathRef]) = diff --git a/scalalib/test/src/mill/scalalib/GenIdeaTests.scala b/scalalib/test/src/mill/scalalib/GenIdeaTests.scala index d49e6a1c..ae5810df 100644 --- a/scalalib/test/src/mill/scalalib/GenIdeaTests.scala +++ b/scalalib/test/src/mill/scalalib/GenIdeaTests.scala @@ -29,10 +29,10 @@ object GenIdeaTests extends TestSuite { def tests: Tests = Tests { 'genIdeaTests - { helloWorldEvaluator(HelloWorld.scalaVersion) - val x = GenIdea.xmlFileLayout(helloWorldEvaluator.evaluator, HelloWorld) val pp = new scala.xml.PrettyPrinter(999, 4) - for((relPath, xml) <- GenIdea.xmlFileLayout(helloWorldEvaluator.evaluator, HelloWorld)){ + val layout = GenIdea.xmlFileLayout(helloWorldEvaluator.evaluator, HelloWorld, fetchMillModules = false) + for((relPath, xml) <- layout){ write.over(basePath/ "generated"/ relPath, pp.format(xml)) } @@ -60,7 +60,7 @@ object GenIdeaTests extends TestSuite { "gen-idea/idea/modules.xml" -> basePath / "generated" / ".idea" / "modules.xml", "gen-idea/idea/misc.xml" -> - basePath / "generated" / ".idea" / "misc.xml", + basePath / "generated" / ".idea" / "misc.xml" ).foreach { case (resource, generated) => val resourceString = scala.io.Source.fromResource(resource).getLines().mkString("\n") val generatedString = normaliseLibraryPaths(read! generated) -- cgit v1.2.3