Search code examples
scalaplayframeworkakkalagom

What is the Main class in a Lagom/Play application?


I'm trying to figure out how to package and deploy my lagom app in production. The docs are surprisingly coy about how to actually do this, and when I try to use sbt-native-packager to run universal:packageBin I get the warning that You have no main class in your project. No start script will be generated.

Has anyone worked through this and knows a good tutorial or something to reference?


Solution

  • https://github.com/lagom/lagom/blob/a35fab1ad8a0c4a3d28d6c86ae31a2408da2e340/dev/sbt-plugin/src/main/scala/com/lightbend/lagom/sbt/LagomSettings.scala#L28

    Adding that to your project will fix it. That said, generally you shouldn't see this warning, because the Lagom plugin should configure it for you. There's two reasons that I can think of off the top of my head why you might be seeing this warning.

    The first would be that you don't have the Lagom plugin enabled on your project. If that's the case, and you're not doing something advanced where you really know what you're doing (and if you really knew what you were doing I would be surprised if you had to ask this question), then you probably have a misconfiguration and need to enable the Lagom plugin.

    The second might be that you're running universal:packageBin on multiple projects, some of which do have the Lagom plugin enabled, and some of which don't. In such a case, you probably only want to build the production artifact for your Lagom project, not for all the other projects (eg the API project, or the root project). So, just run it for your service (eg, run my-service-impl/universal:packageBin).