Desktop version

Home arrow Computer Science arrow Building Applications with Scala

Source

Activator shell

Activator allows you to run REPL like we did in Scala and SBT. In order to get REPL access, you need to type the following on the console:

$ activator shell

Activator has plenty of tasks that you can use. In order to know all the available commands, you can type $ activator help on the console.

Activator - compiling, testing, and running

Let's get to business now. We will compile, run tests, and run our web application using Activator and SBT. First of all, let's compile. Type $ activator compile on the console as follows:

$ activator compile

diego@4winds:~/bin/activator-1.3.10-minimal/bin/ReactiveWebStore$ activator compile

[info] Loading global plugins from /home/diego/.sbt/0.13/plugins

[info] Loading project definition from /home/diego/bin/activator-

1.3.10-minimal/bin/ReactiveWebStore/project

[info] Set current project to ReactiveWebStore (in build

file:/home/diego/bin/activator-1.3.10-

minimal/bin/ReactiveWebStore/)

[info] Updating {file:/home/diego/bin/activator-1.3.10- minimal/bin/ReactiveWebStore/}root...

[info] Compiling 14 Scala sources and 1 Java source to /home/diego/bin/activator-1.3.10-

minimal/bin/ReactiveWebStore/target/scala-2.11/classes...

[success] Total time: 154 s, completed 14/05/2016 19:28:03 diego@4winds:~/bin/activator-1.3.10-minimal/bin/ReactiveWebStore$

Let's run our tests now with the command $ activator test.

Finally, it's time to run your application. Type $ activator run on the console.

Open your web browser, and go to the URL: http ://iocaihost:9000.

You should see a screen like the following:

Summary

Congratulations! You've just Bootstrapped your first Scala / Play framework first. Activator makes our life easier. As you can see, with three commands, we were able to get a site up and running. You could do the same with just SBT, however, it would take more time, because we would need to get all the dependencies, configure all the source code structure, and add some sample HTML and Scala code. Thanks to Activator, we don't need to do any of that. However, we can still change all the SBT files and configs as per our wish. Activator is not tight with Scala or our application code, since it is more like a template-based code generator.

In the next chapter, we will be improving the application by adding validations, database persistence, Reactive Microservices calling using RxScala and Scala, and much more.

3

 
Source
Found a mistake? Please highlight the word and press Shift + Enter  
< Prev   CONTENTS   Next >

Related topics