diff options
-rw-r--r-- | build.sbt | 4 | ||||
-rwxr-xr-x | build.sc | 14 | ||||
-rw-r--r-- | scalalib/src/main/scala/mill/scalalib/GenIdea.scala | 34 | ||||
-rw-r--r-- | scalalib/src/main/scala/mill/scalalib/Module.scala | 5 | ||||
-rw-r--r-- | shared.sc | 4 |
5 files changed, 40 insertions, 21 deletions
@@ -96,13 +96,13 @@ lazy val core = project "org.scala-sbt" % "test-interface" % "1.0" ), sourceGenerators in Compile += { - ammoniteRun(sourceManaged in Compile, List("shared.sc", "generateSources", _)) + ammoniteRun(sourceManaged in Compile, List("shared.sc", "generateCoreSources", _)) .taskValue .map(x => (x ** "*.scala").get) }, sourceGenerators in Test += { - ammoniteRun(sourceManaged in Test, List("shared.sc", "generateTests", _)) + ammoniteRun(sourceManaged in Test, List("shared.sc", "generateCoreTestSources", _)) .taskValue .map(x => (x ** "*.scala").get) } @@ -58,22 +58,22 @@ object core extends MillModule { Dep.Java("org.scala-sbt", "test-interface", "1.0") ) - def generatedSources = T{ + def generatedCoreSources = T{ mkdir(T.ctx().dest) - shared.generateSources(T.ctx().dest) + shared.generateCoreSources(T.ctx().dest) PathRef(T.ctx().dest) } - def allSources = super.allSources() ++ Seq(generatedSources()) + def generatedSources = T { super.generatedSources() ++ Seq(generatedCoreSources()) } + val test = new Tests(implicitly) class Tests(ctx0: mill.Module.Ctx) extends super.Tests(ctx0){ - def generatedSources = T{ + def generatedCoreTestSources = T{ mkdir(T.ctx().dest) - shared.generateTests(T.ctx().dest) + shared.generateCoreTestSources(T.ctx().dest) PathRef(T.ctx().dest) - } - def allSources = super.allSources() ++ Seq(generatedSources()) + def generatedSources = T { super.generatedSources() ++ Seq(generatedCoreTestSources()) } } } 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 } @@ -133,14 +133,14 @@ def unpackZip(zipDest: Path, url: String) = { } @main -def generateSources(p: Path) = { +def generateCoreSources(p: Path) = { generateApplyer(p) generateTarget(p) generateEval(p) } @main -def generateTests(p: Path) = { +def generateCoreTestSources(p: Path) = { generateApplicativeTest(p) } |