From e8f53585e555cec800063cddc763a2837f4c5260 Mon Sep 17 00:00:00 2001 From: Minghao Liu Date: Fri, 12 Jan 2018 14:43:53 +0800 Subject: Add generated sources target (#109) * add generated source * naming * multiple content root * no message * fix output classes path --- .../src/main/scala/mill/scalalib/GenIdea.scala | 34 +++++++++++++++++----- scalalib/src/main/scala/mill/scalalib/Module.scala | 5 ++-- 2 files changed, 29 insertions(+), 10 deletions(-) (limited to 'scalalib') diff --git a/scalalib/src/main/scala/mill/scalalib/GenIdea.scala b/scalalib/src/main/scala/mill/scalalib/GenIdea.scala index 54c1b3ac..24daef2c 100644 --- a/scalalib/src/main/scala/mill/scalalib/GenIdea.scala +++ b/scalalib/src/main/scala/mill/scalalib/GenIdea.scala @@ -72,8 +72,11 @@ object GenIdea { } val moduleFiles = resolved.map{ case (path, resolvedDeps, mod) => - val Seq(sourcePath: PathRef) = - evaluator.evaluate(OSet(mod.sources)).values + val Seq(sourcesPathRef: PathRef, generatedSourcePathRefs: Seq[PathRef], allSourcesPathRefs: Seq[PathRef]) = + evaluator.evaluate(OSet(mod.sources, mod.generatedSources, mod.allSources)).values + + val generatedSourcePaths = generatedSourcePathRefs.map(_.path) + val normalSourcePaths = (allSourcesPathRefs.map(_.path).toSet -- generatedSourcePaths.toSet).toSeq val paths = Evaluator.resolveDestPaths( evaluator.workspacePath, @@ -81,7 +84,9 @@ object GenIdea { ) val elem = moduleXmlTemplate( - sourcePath.path, + sourcesPathRef.path, + normalSourcePaths, + generatedSourcePaths, Seq(paths.out), resolvedDeps.map(pathToLibName), for(m <- mod.projectDeps) @@ -150,7 +155,9 @@ object GenIdea { } - def moduleXmlTemplate(sourcePath: Path, + def moduleXmlTemplate(basePath: Path, + normalSourcePaths: Seq[Path], + generatedSourcePaths: Seq[Path], outputPaths: Seq[Path], libNames: Seq[String], depNames: Seq[String]) = { @@ -158,13 +165,24 @@ object GenIdea { { for(outputPath <- outputPaths) - yield + yield } - - - + { + for (normalSourcePath <- normalSourcePaths) + yield + + + + } + { + for (generatedSourcePath <- generatedSourcePaths) + yield + + + + } diff --git a/scalalib/src/main/scala/mill/scalalib/Module.scala b/scalalib/src/main/scala/mill/scalalib/Module.scala index dbccbec1..4437c08f 100644 --- a/scalalib/src/main/scala/mill/scalalib/Module.scala +++ b/scalalib/src/main/scala/mill/scalalib/Module.scala @@ -193,7 +193,8 @@ trait Module extends mill.Module with TaskModule { outer => def sources = T.source{ basePath / 'src } def resources = T.source{ basePath / 'resources } - def allSources = T{ Seq(sources()) } + def generatedSources = T { Seq.empty[PathRef] } + def allSources = T{ Seq(sources()) ++ generatedSources() } def compile: T[CompilationResult] = T.persistent{ compileScala( ZincWorker(), @@ -361,7 +362,7 @@ trait PublishModule extends Module { outer => trait SbtModule extends Module { outer => override def sources = T.source{ basePath / 'src / 'main / 'scala } override def resources = T.source{ basePath / 'src / 'main / 'resources } - trait Tests extends super.Tests{ + trait Tests extends super.Tests { override def basePath = outer.basePath override def sources = T.source{ basePath / 'src / 'test / 'scala } override def resources = T.source{ basePath / 'src / 'test / 'resources } -- cgit v1.2.3