Home Computer Science
Bootstrapping our Play framework app with Activator
Lightband (former Typesafe) has another tool called Activator (https ://www. lightbend. co m/community/core-tools/activator-and-sbt), which is a wrapper on top of SBT. Activator makes it easier to create Reactive applications using Scala, Akka, and the Play framework. Don't worry about the Play framework right now, because we will cover that in greater detail in Chapter 3, Developing the UI with Play Framework. Akka will be covered in detail in Chapter 8, Developing a chat with Akka.
Let's download and install Activator, and Bootstrap our architecture. Remember, we need to have Java 8 and Scala 2.11 already installed. If you don't have Java 8 or Scala 2.11, go back
to Chapter 1, Introduction to FP, Reactive, and Scala and install them.
First of all, you need to download activator from here: https ://www. lightbend.com/activ ator/download
I recommend that you download the minimal package, and let Activator download and install the rest of the other dependencies for you. You can download the minimal package
here: https://downloads.typesafe.com/typesafe-act ivator/1.3.10/typesafe-activa tor-1.3.10-minimal.zip.
For this book, we will be using version 1.3.10. We need to put the activator/bin folder in the OS PATH.If you want, you can install Activator using the terminal, like this:
If you want, you can install Activator using the terminal, like this:
$ cd /usr/local/
$ wget https://downloads.typesafe.com/typesafe- activator/1.3.10/typesafe-activator-1.3.10-minimal.zip $ tar -xzf typesafe-activator-1.3.10-minimal.zip $ rm -rf typesafe-activator-1.3.10-minimal.zip $ sudo echo 'export PATH=$PATH:/usr/local/typesafe-activator- 1.3.10-minimal/bin' >> ~/.bashrc $ source >> ~/.bashrc
In order to test your installation, execute this command:
$ activator new ReactiveWebStore
The preceding command will Bootstrap an architecture for you with Scala, Akka, Play framework, and SBT.
Activator will ask you a series of questions like such as what templates you might like to use. There are a couple of templates for Java applications, Scala applications, Akka applications, and Play applications. For now, we will pick option 6) play-scala.
The first time you run Activator, it could take some time, because it will download all the dependencies from the web. When Activator finishes, you should see a folder called
ReactiveWebStore in your file system.
The command $ activator new ReactiveWebStore shows the following result:
You should enter the ReactiveWebStore folder if you type $ ll into the console, and you should also see the following structure:
drwxrwxr-x 9 diego diego 4096 Mai 14 19:03 ./
drwxr-xr-x 3 diego diego 4096 Mai 14 19:03 ../
drwxrwxr-x 6 diego diego 4096 Mai 14 19:03 app/
drwxrwxr-x 2 diego diego 4096 Mai 14 19:03 bin/
drwxrwxr-x 5 diego diego 4096 Mai 14 19:03 public/
-rw-rw-r— 1 diego diego 1063 Mai 14 19:03 README
drwxrwxr-x 2 diego diego 4096 Mai 14 19:03 test/
The content is explained as follows: