0
votes

I've started off with a single Play Framework 2.x project (Scala) that I've been working on.

This has now reached a point where I'd like to break down the project into a number of sub and 'sibiling' projects. Specifically - I'm writing a Play REST API service that I wish to also build a Javascript project alongside of like an 'SDK' for the service.

I 'think' this is possible using SBT - but I'm stuck and the documentation seems thin on the ground in this area.

I'd like to have three projects underneath one 'main' project that is nothing but a container for the other three and where the main build files are.

This would be something like:

  • main
    • service (play + scala)
      • common files (scala only)
    • sdk (javascript)

When I try and run 'play' to build the hierachy I've got - I get variations on the following error:

[error] Not a valid command: play (similar: apply, last, alias)
[error] Not a valid project ID: play
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: play (similar: playConf, play-conf, playReload)
[error] play
[error]     ^

When I have a Build.scala (in the 'main' project) look like this:

object ApplicationBuild extends Build {

val appName = "my service"
val appVersion = "1.0-SNAPSHOT"

// tell the couchbase infrastructure to use the built in logger - which will get redirected to our main logger
System.setProperty("net.spy.log.LoggerImpl", "net.spy.memcached.compat.log.SunLogger")

// project dependencies
val appDependencies = Seq(
    ...
    )

val common = Project("common", file("common"))

val service = play.Project(appName, appVersion, appDependencies, path = file("service")).settings(
        scalacOptions ++= Seq("-feature") // turn on normal warnings and feature warnings with scalac
    ).dependsOn(common)

val sdk = Project("sdk", file("sdk"))

val base = Project("base", file("."))
    .dependsOn(service)
    .dependsOn(sdk)
    .dependsOn(common)
}

The folder hierachy I've got is:

\
    \service
    \common
    \sdk
    \project
    \target
    build.sbt

Am I on the right track and can someone help me out syntax wise, or am I approaching the problem in completely the wrong way and play cannot be used like that? (use sbt directly?).

2

2 Answers

0
votes

I think your base project should look like this:

val base = Project("base", file("."))
.aggregate(service,sdk,common)
0
votes

First, a project is defined by declaring a lazy val of type Project because you may encounter initialization problems.

lazy val base = Project("base", file(".")).aggregate(sdk, service, common)

If you have SBT installed and configured classpath for SBT, try sbt command in the terminal. The current project should be set to "base" automatically.

The reason I suggested you to try sbt command instead of play command is: If the root project is not a PlayProject then the play build script will fail.