Update:
So, the issue I'm trying to understand is why I can't have a build.sbt
in the root folder. Even if I define a lazy val root = ...
in the root build.sbt
folder, the main class is not found.
This reddit link:
https://www.reddit.com/r/scala/comments/4igc9x/sbt_playframework_no_main_class_detected/
suggests a solution to the problem. While sbt demo/run
does execute the play app, I'd like to eventually just have sbt run
from the root project compile and all the projects and then run the server.
Can anyone help out here?
=================================================================
Old question:
I'm trying to understand how build.sbt works, and I'm not sure what's going on. I'd like to build a play project as one of multiple projects being build under a root build.sbt file.
I have the following structure (most files left out for brevity):
.
|-- build.sbt
|-- project/
| |-- build.properties
| |-- plugins.sbt
| |-- project/
|-- demo/
| |-- build.sbt
| |-- app/
| |-- conf/
| | |-- application.conf
| | |-- routes
| |-- public/
| |-- test/
inside the root dir build.sbt
file, I have the following.
name := "demo-root"
organization := "com.example"
scalaVersion in ThisBuild := "2.11.11"
lazy val root = (project in file("."))
.dependsOn(demo)
.aggregate(demo)
lazy val demo = project
.enablePlugins(PlayScala)
I've defined addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.5.14")
inside plugins.sbt
in the root project/
.
inside the demo/build.sbt
I have
name := "demo"
version in ThisBuild := "1.0-SNAPSHOT"
libraryDependencies += filters
libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" % "2.0.0" % Test
Now, when I perform sbt run
, I receive the following error:
java.lang.RuntimeException: No main class detected.
at scala.sys.package$.error(package.scala:27)
[trace] Stack trace suppressed: run last root/compile:run for the full output.
[error] (root/compile:run) No main class detected.
However if I put the root build.sbt
and root project/
inside of demo/
and try to sbt run
, the project compiles successfully and I can access the play server in the regular way.
Why is this error being thrown? Do I need to explicitly declare a main class for the play project in the root build.sbt
? I'm following the instructions at http://www.scala-sbt.org/0.13/docs/Multi-Project.html, and I'm just a little lost. Any help in the right direction would be appreciated.
For reference ---
sbt version: 0.13.15
scala version: 2.11.11
play plugin version: 2.5.14