From 3a6a3c59217193ec2138ea3cb81dc33b85ea609b Mon Sep 17 00:00:00 2001 From: rockjam <5min4eq.unity@gmail.com> Date: Sun, 15 Apr 2018 22:46:14 +0300 Subject: [PATCH 1/3] mark test module as test sources --- scalalib/src/mill/scalalib/GenIdeaImpl.scala | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/scalalib/src/mill/scalalib/GenIdeaImpl.scala b/scalalib/src/mill/scalalib/GenIdeaImpl.scala index 760f283548e..40437164f40 100644 --- a/scalalib/src/mill/scalalib/GenIdeaImpl.scala +++ b/scalalib/src/mill/scalalib/GenIdeaImpl.scala @@ -214,6 +214,8 @@ object GenIdeaImpl { mod.generatedSources.ctx.segments ) + val isTest = mod.isInstanceOf[TestModule] + val elem = moduleXmlTemplate( mod.millModuleBasePath.value, scalaVersionOpt, @@ -223,7 +225,8 @@ object GenIdeaImpl { paths.out, generatedSourceOutPath.dest, Strict.Agg.from(resolvedDeps.map(pathToLibName)), - Strict.Agg.from(mod.moduleDeps.map{ m => moduleName(moduleLabels(m))}.distinct) + Strict.Agg.from(mod.moduleDeps.map{ m => moduleName(moduleLabels(m))}.distinct), + isTest ) Tuple2(".idea_modules"/s"${moduleName(path)}.iml", elem) } @@ -321,7 +324,9 @@ object GenIdeaImpl { compileOutputPath: Path, generatedSourceOutputPath: Path, libNames: Strict.Agg[String], - depNames: Strict.Agg[String]) = { + depNames: Strict.Agg[String], + isTest: Boolean + ) = { @@ -331,17 +336,17 @@ object GenIdeaImpl { { for (normalSourcePath <- normalSourcePaths.toSeq.sorted) yield - + } { for (generatedSourcePath <- generatedSourcePaths.toSeq.sorted) yield - + } { for (resourcePath <- resourcePaths.toSeq.sorted) yield - + } From ff572f24ced09cdaff7111d60498409afdda4e07 Mon Sep 17 00:00:00 2001 From: rockjam <5min4eq.unity@gmail.com> Date: Mon, 16 Apr 2018 00:07:52 +0300 Subject: [PATCH 2/3] add test case for test module in GenIdea --- .../test/resources/gen-idea/idea/modules.xml | 3 ++- .../resources/gen-idea/idea_modules/test.iml | 18 ++++++++++++++++++ .../test/src/mill/scalalib/GenIdeaTests.scala | 5 +++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 scalalib/test/resources/gen-idea/idea_modules/test.iml diff --git a/scalalib/test/resources/gen-idea/idea/modules.xml b/scalalib/test/resources/gen-idea/idea/modules.xml index d7cfbd0866c..d6334ea357d 100644 --- a/scalalib/test/resources/gen-idea/idea/modules.xml +++ b/scalalib/test/resources/gen-idea/idea/modules.xml @@ -3,6 +3,7 @@ + - \ No newline at end of file + diff --git a/scalalib/test/resources/gen-idea/idea_modules/test.iml b/scalalib/test/resources/gen-idea/idea_modules/test.iml new file mode 100644 index 00000000000..f67445ae893 --- /dev/null +++ b/scalalib/test/resources/gen-idea/idea_modules/test.iml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/scalalib/test/src/mill/scalalib/GenIdeaTests.scala b/scalalib/test/src/mill/scalalib/GenIdeaTests.scala index dc8faaf4d8d..b21c070c7a2 100644 --- a/scalalib/test/src/mill/scalalib/GenIdeaTests.scala +++ b/scalalib/test/src/mill/scalalib/GenIdeaTests.scala @@ -13,6 +13,9 @@ object GenIdeaTests extends TestSuite { trait HelloWorldModule extends scalalib.ScalaModule { def scalaVersion = "2.12.4" def millSourcePath = GenIdeaTests.millSourcePath + object test extends super.Tests { + def testFrameworks = Seq("utest.runner.Framework") + } } object HelloWorld extends TestUtil.BaseModule with HelloWorldModule @@ -34,6 +37,8 @@ object GenIdeaTests extends TestSuite { Seq( "gen-idea/idea_modules/iml" -> millSourcePath / "generated" / ".idea_modules" /".iml", + "gen-idea/idea_modules/test.iml" -> + millSourcePath / "generated" / ".idea_modules" /"test.iml", "gen-idea/idea_modules/mill-build.iml" -> millSourcePath / "generated" / ".idea_modules" /"mill-build.iml", "gen-idea/idea/libraries/scala-library-2.12.4.jar.xml" -> From 50fccd4995d818c0469ff8a16f45817de7c2201c Mon Sep 17 00:00:00 2001 From: rockjam <5min4eq.unity@gmail.com> Date: Thu, 19 Apr 2018 02:26:29 +0300 Subject: [PATCH 3/3] fixes #201 change mill project path for sbt and maven tests --- scalalib/src/mill/scalalib/GenIdeaImpl.scala | 2 +- scalalib/src/mill/scalalib/JavaModule.scala | 2 ++ scalalib/src/mill/scalalib/MiscModule.scala | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/scalalib/src/mill/scalalib/GenIdeaImpl.scala b/scalalib/src/mill/scalalib/GenIdeaImpl.scala index 40437164f40..7ab6ffb7945 100644 --- a/scalalib/src/mill/scalalib/GenIdeaImpl.scala +++ b/scalalib/src/mill/scalalib/GenIdeaImpl.scala @@ -217,7 +217,7 @@ object GenIdeaImpl { val isTest = mod.isInstanceOf[TestModule] val elem = moduleXmlTemplate( - mod.millModuleBasePath.value, + mod.intellijModulePath, scalaVersionOpt, Strict.Agg.from(resourcesPathRefs.map(_.path)), Strict.Agg.from(normalSourcePaths), diff --git a/scalalib/src/mill/scalalib/JavaModule.scala b/scalalib/src/mill/scalalib/JavaModule.scala index 4b90331c946..740bca2b240 100644 --- a/scalalib/src/mill/scalalib/JavaModule.scala +++ b/scalalib/src/mill/scalalib/JavaModule.scala @@ -289,6 +289,8 @@ trait JavaModule extends mill.Module with TaskModule { outer => def artifactName: T[String] = millModuleSegments.parts.mkString("-") def artifactId: T[String] = artifactName() + + def intellijModulePath: Path = millSourcePath } trait TestModule extends JavaModule with TaskModule { diff --git a/scalalib/src/mill/scalalib/MiscModule.scala b/scalalib/src/mill/scalalib/MiscModule.scala index 0e8bde3e638..02a6ebf926e 100644 --- a/scalalib/src/mill/scalalib/MiscModule.scala +++ b/scalalib/src/mill/scalalib/MiscModule.scala @@ -66,12 +66,14 @@ trait MavenModule extends JavaModule{outer => override def resources = T.sources{ millSourcePath / 'src / 'main / 'resources } trait Tests extends super.Tests with MavenTests { override def millSourcePath = outer.millSourcePath + override def intellijModulePath = outer.millSourcePath / 'src / 'test } } trait SbtModule extends MavenModule with ScalaModule{ outer => trait Tests extends super.Tests with MavenTests { override def millSourcePath = outer.millSourcePath + override def intellijModulePath = outer.millSourcePath / 'src / 'test } }