From 0de4e890201315458cb438f933179afafc780f94 Mon Sep 17 00:00:00 2001 From: Tobias Roeser Date: Fri, 20 Sep 2019 22:03:35 +0200 Subject: Use a dedicated path/target for idea compiler output (#694) * Use a dedicated path/target for idea compiler output Fixes https://github.com/lihaoyi/mill/issues/693 * Fixed xml generator and test cases --- scalalib/src/GenIdeaImpl.scala | 21 ++++++++++++--------- scalalib/src/GenIdeaModule.scala | 6 ++++-- .../idea_modules/helloworld.iml | 2 +- .../idea_modules/helloworld.test.iml | 2 +- .../idea_modules/helloworld.iml | 2 +- .../idea_modules/helloworld.test.iml | 2 +- 6 files changed, 20 insertions(+), 15 deletions(-) diff --git a/scalalib/src/GenIdeaImpl.scala b/scalalib/src/GenIdeaImpl.scala index f91eadaf..f1483d8a 100755 --- a/scalalib/src/GenIdeaImpl.scala +++ b/scalalib/src/GenIdeaImpl.scala @@ -119,7 +119,8 @@ case class GenIdeaImpl(evaluator: Evaluator, compilerClasspath: Loose.Agg[Path], libraryClasspath: Loose.Agg[Path], facets: Seq[JavaFacet], - configFileContributions: Seq[IdeaConfigFile] + configFileContributions: Seq[IdeaConfigFile], + compilerOutput: Path ) val resolved = evalOrElse(evaluator, Task.sequence(for((path, mod) <- modules) yield { @@ -164,6 +165,10 @@ case class GenIdeaImpl(evaluator: Evaluator, mod.ideaConfigFiles(ideaConfigVersion)() } + val compilerOutput = T.task{ + mod.ideaCompileOutput() + } + T.task { val resolvedCp: Loose.Agg[PathRef] = externalDependencies() val resolvedSrcs: Loose.Agg[PathRef] = externalSources() @@ -173,6 +178,7 @@ case class GenIdeaImpl(evaluator: Evaluator, val scalacOpts: Seq[String] = scalacOptions() val resolvedFacets: Seq[JavaFacet] = facets() val resolvedConfigFileContributions: Seq[IdeaConfigFile] = configFileContributions() + val resolvedCompilerOutput = compilerOutput() ResolvedModule( path, @@ -183,7 +189,8 @@ case class GenIdeaImpl(evaluator: Evaluator, resolvedCompilerCp.map(_.path), resolvedLibraryCp.map(_.path), resolvedFacets, - resolvedConfigFileContributions + resolvedConfigFileContributions, + resolvedCompilerOutput.path ) } }), Seq()) @@ -328,7 +335,7 @@ case class GenIdeaImpl(evaluator: Evaluator, for(name <- names) yield Tuple2(os.rel/".idea"/'libraries/s"$name.xml", libraryXmlTemplate(name, path, sources, librariesProperties.getOrElse(path, Loose.Agg.empty))) } - val moduleFiles = resolved.map{ case ResolvedModule(path, resolvedDeps, mod, _, _, _, _, facets, _) => + val moduleFiles = resolved.map{ case ResolvedModule(path, resolvedDeps, mod, _, _, _, _, facets, _, compilerOutput) => val Seq( resourcesPathRefs: Seq[PathRef], sourcesPathRef: Seq[PathRef], @@ -339,10 +346,6 @@ case class GenIdeaImpl(evaluator: Evaluator, val generatedSourcePaths = generatedSourcePathRefs.map(_.path) val normalSourcePaths = (allSourcesPathRefs.map(_.path).toSet -- generatedSourcePaths.toSet).toSeq - val paths = Evaluator.resolveDestPaths( - evaluator.outPath, - mod.compile.ctx.segments - ) val scalaVersionOpt = mod match { case x: ScalaModule => Some(evaluator.evaluate(Agg(x.scalaVersion)).values.head.asInstanceOf[String]) case _ => None @@ -360,7 +363,7 @@ case class GenIdeaImpl(evaluator: Evaluator, Strict.Agg.from(resourcesPathRefs.map(_.path)), Strict.Agg.from(normalSourcePaths), Strict.Agg.from(generatedSourcePaths), - paths.out, + compilerOutput, generatedSourceOutPath.dest, Strict.Agg.from(resolvedDeps.map(pathToLibName)), Strict.Agg.from(mod.moduleDeps.map{ m => moduleName(moduleLabels(m))}.distinct), @@ -505,7 +508,7 @@ case class GenIdeaImpl(evaluator: Evaluator, { - val outputUrl = "file://$MODULE_DIR$/" + relify(compileOutputPath) + "/dest/classes" + val outputUrl = "file://$MODULE_DIR$/" + relify(compileOutputPath) if (isTest) else diff --git a/scalalib/src/GenIdeaModule.scala b/scalalib/src/GenIdeaModule.scala index e874da8b..5deb5c7e 100644 --- a/scalalib/src/GenIdeaModule.scala +++ b/scalalib/src/GenIdeaModule.scala @@ -1,7 +1,7 @@ package mill.scalalib import mill.define.Command -import mill.{Module, T} +import mill.{Module, PathRef, T} /** * Module specific configuration of the Idea project file generator. @@ -28,7 +28,9 @@ trait GenIdeaModule extends Module { */ def ideaConfigFiles(ideaConfigVersion: Int): Command[Seq[IdeaConfigFile]] = T.command { Seq[IdeaConfigFile]() } - } + def ideaCompileOutput: T[PathRef] = T.persistent { PathRef(T.ctx().dest / "classes") } + +} object GenIdeaModule { import upickle.default._ diff --git a/scalalib/test/resources/gen-idea-extended-hello-world/idea_modules/helloworld.iml b/scalalib/test/resources/gen-idea-extended-hello-world/idea_modules/helloworld.iml index 94810f20..8d00490f 100644 --- a/scalalib/test/resources/gen-idea-extended-hello-world/idea_modules/helloworld.iml +++ b/scalalib/test/resources/gen-idea-extended-hello-world/idea_modules/helloworld.iml @@ -1,6 +1,6 @@ - + diff --git a/scalalib/test/resources/gen-idea-extended-hello-world/idea_modules/helloworld.test.iml b/scalalib/test/resources/gen-idea-extended-hello-world/idea_modules/helloworld.test.iml index 26fac21d..79be6671 100644 --- a/scalalib/test/resources/gen-idea-extended-hello-world/idea_modules/helloworld.test.iml +++ b/scalalib/test/resources/gen-idea-extended-hello-world/idea_modules/helloworld.test.iml @@ -1,6 +1,6 @@ - + diff --git a/scalalib/test/resources/gen-idea-hello-world/idea_modules/helloworld.iml b/scalalib/test/resources/gen-idea-hello-world/idea_modules/helloworld.iml index 6808e515..cc3c0ce2 100644 --- a/scalalib/test/resources/gen-idea-hello-world/idea_modules/helloworld.iml +++ b/scalalib/test/resources/gen-idea-hello-world/idea_modules/helloworld.iml @@ -1,6 +1,6 @@ - + diff --git a/scalalib/test/resources/gen-idea-hello-world/idea_modules/helloworld.test.iml b/scalalib/test/resources/gen-idea-hello-world/idea_modules/helloworld.test.iml index 26fac21d..79be6671 100644 --- a/scalalib/test/resources/gen-idea-hello-world/idea_modules/helloworld.test.iml +++ b/scalalib/test/resources/gen-idea-hello-world/idea_modules/helloworld.test.iml @@ -1,6 +1,6 @@ - + -- cgit v1.2.3