summaryrefslogtreecommitdiff
path: root/scalalib/src/GenIdeaModule.scala
blob: e874da8b17cbed81d5c7dbd0efc6a7799583db90 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package mill.scalalib

import mill.define.Command
import mill.{Module, T}

/**
 * Module specific configuration of the Idea project file generator.
 */
trait GenIdeaModule extends Module {
  import GenIdeaModule._

  def intellijModulePath: os.Path = millSourcePath

  /**
    * Skip Idea project file generation.
    */
  def skipIdea: Boolean = false

  /**
    * Contribute facets to the Java module configuration.
    * @param ideaConfigVersion The IDEA configuration version in use. Probably `4`.
    * @return
    */
  def ideaJavaModuleFacets(ideaConfigVersion: Int): Command[Seq[JavaFacet]] = T.command { Seq[JavaFacet]() }

  /**
    * Contribute components to idea config files.
    */
  def ideaConfigFiles(ideaConfigVersion: Int): Command[Seq[IdeaConfigFile]] = T.command { Seq[IdeaConfigFile]() }

  }

object GenIdeaModule {
  import upickle.default._

  case class Element(name: String, attributes: Map[String, String] = Map(), childs: Seq[Element] = Seq())
  object Element {
    implicit def rw: ReadWriter[Element] = macroRW
  }

  final case class JavaFacet(`type`: String, name: String, config: Element)
  object JavaFacet {
    implicit def rw: ReadWriter[JavaFacet] = macroRW
  }

  final case class IdeaConfigFile(name: String, component: String, config: Seq[Element])
  object IdeaConfigFile {
    implicit def rw: ReadWriter[IdeaConfigFile] = macroRW
  }

}