diff options
Diffstat (limited to 'scalalib/src')
-rw-r--r-- | scalalib/src/main/scala/mill/scalalib/GenIdea.scala | 34 | ||||
-rw-r--r-- | scalalib/src/main/scala/mill/scalalib/Module.scala | 5 |
2 files changed, 29 insertions, 10 deletions
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 { </library> </component> } - 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 { <component name="NewModuleRootManager"> { for(outputPath <- outputPaths) - yield <output url={"file://$MODULE_DIR$/" + relify(outputPath)} /> + yield <output url={"file://$MODULE_DIR$/" + relify(outputPath) + "/dest/classes"} /> } <exclude-output /> - <content url={"file://$MODULE_DIR$/" + relify(sourcePath)}> - <sourceFolder url={"file://$MODULE_DIR$/" + relify(sourcePath)} isTestSource="false" /> - </content> + { + for (normalSourcePath <- normalSourcePaths) + yield + <content url={"file://$MODULE_DIR$/" + relify(normalSourcePath)}> + <sourceFolder url={"file://$MODULE_DIR$/" + relify(normalSourcePath)} isTestSource="false" /> + </content> + } + { + for (generatedSourcePath <- generatedSourcePaths) + yield + <content url={"file://$MODULE_DIR$/" + relify(generatedSourcePath)}> + <sourceFolder url={"file://$MODULE_DIR$/" + relify(generatedSourcePath)} isTestSource="false" generated="true" /> + </content> + } <orderEntry type="inheritedJdk" /> <orderEntry type="sourceFolder" forTests="false" /> 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 } |