The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

drouchy (1) [Avatar] Offline

I've been reading your book, and so far so good smilie

I've got a comment thought. There is no explanation how to configure Scalatra from scratch on a project - I mean without g8 - That would be great to understand how Scalatra works, how to configure it before using a "magic script" that does everything for you.


StefanOllinger (8) [Avatar] Offline
Re: Scalatra from scratch

basically you need to configure a build for your build tool (if you dont use one, start using one).
We are targetting mainly SBT in order to compile, test and package an application.
The first thing you need to do is to define the dependencies in the correct scope (compile, test, runtime). There are quite some dependencies, but most importantly are:

* scalatra: Scalatra core
* scalatra-specs2: testing integration, there is also scalata-scalatest
* scalatra-scalate: Scalate module
* logback-classic: for logging

Most things should work with other build tools (Maven, Gradle) as well. One tricky thing could be setting up a development mode. In SBT we integrate the xsbt-web-plugin which supplies the development servlet container (on container:start).

After you have the build ready you need to setup the structure of the application, which includes creating directories. In Maven layout this is: src/main/scala, src/main/resources, src/main/webapp. Then you can start writing the application.

This is quite a labor-consuming task to do manually, therefore I strongly suggest to use a template. But on the other hand knowing the what and why is really useful.

Chapter 12 is going to write about the structure of a Scalatra application using the SBT build tool. There you will learn more about the resources, lifecycle and configuration aspects.

I hope this helped. If you have any more questions, feel free to ask.