Search code examples
intellij-ideaplayframework-2.0subproject

How to create subprojects inside Play with Intellij?


Currently I have the following Play project structure:

  • PlayApp
    • modules
      • common
      • sub_project_two

PlayApp is marked as a module, dependent on common.

modules is just a directory.

common is a sub project(also a play app).

sub_project_two is a sub project(also a play app), which is dependent on common.

Unfortunately I cannot just right click on "modules" and create new module(play app) and move on. Currently, I literally have to right click PlayApp and create the new module then move it to "modules", and it is running into dependency issues in Intellij and failing to import the classes inside "common".

What is the correct way of creating subprojects inside Intellij?


Solution

  • There is no any special way to create subprojects in Intellij. Subprojects are defined in sbt build file. Intellij will discover these projects and configure them as long as you have Scala plugin. I would imagine a following project structure in your build file:

    lazy val PlayApp = Project("playApp", file(".")).aggregate(common, subProjectTwo)
    lazy val common = Project("common", file("modules/common"))
    lazy val subProjectTwo = Project("subProjectTwo", file("modules/sub_project_two"))
    

    For more details visit: http://www.scala-sbt.org/0.13.5/docs/Getting-Started/Multi-Project.html