Skip to content

Commit

Permalink
Derived new GenIdea module to support meta-builds (#2638)
Browse files Browse the repository at this point in the history
Moved the implementation from `mill.scalalib` to a new module
`mill.idea`. The reason is simple, we need access to the `runner`
module, but `runner` itself depends on `scalalib` to provide compilation
support. Generating an IDE setup has a much broader scope so a dedicated
module is IMHO the best. This is analog to `mill.bsp`, which also
provides IDE support as a dedicated module.

Deprecated the old `mill.scalalib.GenIdea` module.

Enhanced the lookup for modules and root modules to reflect the new
meta-build capabilities of Mill.

Reworked the XML generator to re-respect the
`GenIdeaModule.intellijModulePath` setting and ensured we combine
multiple source folders under the same source root if appropriate.

Pull request: #2638
  • Loading branch information
lefou authored Aug 21, 2023
1 parent b5388e1 commit 6635d2c
Show file tree
Hide file tree
Showing 30 changed files with 1,158 additions and 80 deletions.
10 changes: 7 additions & 3 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -1247,13 +1247,17 @@ object runner extends MillPublishScalaModule {
}
}

object idea extends MillPublishScalaModule {
def moduleDeps = Seq(scalalib, runner)
}

object dist extends MillPublishJavaModule {
def jar = dev.assembly()
def moduleDeps = Seq(runner)
def moduleDeps = Seq(runner, idea)
}

object dev extends MillPublishScalaModule {
def moduleDeps = Seq(runner)
def moduleDeps = Seq(runner, idea)

def testTransitiveDeps = super.testTransitiveDeps() ++ Seq(
runner.linenumbers.testDep(),
Expand Down Expand Up @@ -1437,7 +1441,7 @@ object docs extends Module {
PathRef(workDir / "build" / "site")
}

def source0: Source = T.source(millSourcePath)
def source0 = T.source(millSourcePath)
def source = T {
os.copy(source0().path, T.dest, mergeFolders = true)

Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/Installation_IDE_Support.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ To generate IntelliJ IDEA project files into `.idea/`, run:

[source,bash]
----
mill mill.scalalib.GenIdea/idea
mill mill.idea.GenIdea/idea
----

== Updating Mill
Expand Down
25 changes: 25 additions & 0 deletions idea/src/mill/idea/GenIdea.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package mill.idea

import mill.T
import mill.api.Result
import mill.define.{Command, Discover, ExternalModule}
import mill.eval.Evaluator

import scala.util.control.NonFatal

object GenIdea extends ExternalModule {

def idea(allBootstrapEvaluators: Evaluator.AllBootstrapEvaluators): Command[Unit] = T.command {
try {
Result.Success(GenIdeaImpl(
evaluators = Evaluator.allBootstrapEvaluators.value.value
).run())
} catch {
case GenIdeaImpl.GenIdeaException(m) => Result.Failure(m)
case NonFatal(e) =>
Result.Exception(e, new Result.OuterStack(new java.lang.Exception().getStackTrace))
}
}

override lazy val millDiscover = Discover[this.type]
}
Loading

0 comments on commit 6635d2c

Please sign in to comment.