Let us understand develop cycle of Scala based application using sbt as build tool. In case, you are newbie for Scala and want to learn it in detail, please go through this course.
Create program file
As we are done with exploring the code to get the revenue for order id 2, let us see the steps to build an application.
- We will not be able to login into production environment and run the code using REPL, hence understanding of building as application and running it is important.
- Create base directory retail
- Create directory structure src/main/scala
mkdir -p src/main/scala
- Now add the code which is presented after the video into file called src/main/scala/orderRevenue.scala
Build and Run jar file
As we have developed the code, let us understand how we can build as application and run.
- Setup sbt
- Under base directory, create build.sbt
sbt package, which will create jar file
- Application can be run using
Setup sbt on Windows
Let us see how we can set up sbt on windows
- Search for sbt and choose 0.13.x
- Download respective MSI
- Install using typical installation
- Validate by running sbt command
Compile and run using arguments
Let us see how we can make modifications to the code
- Make changes to the code to accept order id as argument
- Recompile the program
- Use scala to run the jar file by passing order id as argument