1
votes

I'm trying to add a subproject to my Play Framework project, and find the docs generally lacking there.

I've created a play project, let's call it my-web, and it's in directory /my-cool-project/web. I also have another project I would like my-web to depend on, let's call it my-model. my-model a git submodule for my-cool-project, and when I pull it, my directory structure is

/my-cool-project
     /my-web
         /app
         /conf
         build.sbt
     /my-model
         /main
              /java
                   /src

Now, how do I add my-model as a subproject for my-web? I've tried

lazy val myModel = project.in(file("../my-model"))

but all I get is that my-model is not contained within the build root of my-web... Anything else I can try in build.sbt?

2
A subproject is expected to reside in a subdirectory of the main project.Seth Tisue

2 Answers

2
votes

project is used to define the project model and sub-projects. For sibling project, you can use RootProject or ProjectRef. In your case, I would use RootProject.

lazy val myModel = RootProject(file("../my-model"))

When you compile a project, compilation on all RootProjects and ProjectRefs will triggered as well. You will define your project setting for my-model inside the build file in my-model project. This reduce the duplication for the project definition.

Think about RootProject and ProjectRef like project reference in Eclipse.

Let me know if this is what you are looking for.

1
votes

change lazy val myModel = project.in(file("../my-model"))
to

lazy val myModel = project.in(file("my-model"))

Path it refers is from root of the project. So, you can give this path accordingly.