summaryrefslogtreecommitdiff
path: root/scalalib/src/main/scala/mill/scalalib/GenIdea.scala
diff options
context:
space:
mode:
authorMinghao Liu <molikto@gmail.com>2018-01-12 14:43:53 +0800
committerLi Haoyi <haoyi.sg@gmail.com>2018-01-11 22:43:53 -0800
commite8f53585e555cec800063cddc763a2837f4c5260 (patch)
treed52052274fc63f8e8dfdeddb67baaea2959ba2cd /scalalib/src/main/scala/mill/scalalib/GenIdea.scala
parentf084c2059f1c21c3ac7726f4d06881d6fba7d341 (diff)
downloadmill-e8f53585e555cec800063cddc763a2837f4c5260.tar.gz
mill-e8f53585e555cec800063cddc763a2837f4c5260.tar.bz2
mill-e8f53585e555cec800063cddc763a2837f4c5260.zip
Add generated sources target (#109)
* add generated source * naming * multiple content root * no message * fix output classes path
Diffstat (limited to 'scalalib/src/main/scala/mill/scalalib/GenIdea.scala')
-rw-r--r--scalalib/src/main/scala/mill/scalalib/GenIdea.scala34
1 files changed, 26 insertions, 8 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" />