Set up env for Play Scala framework

Environment

Use the terminal (Mac) and command prompt (Windows) to build the environment. Please refer to the following site for each activation method.

Terminal (Mac)
Tutorial

Command prompt (Windows)
Tutorial

I.Install Homebrew (Mac users only)

On a Mac, we will use a package management system called Homebrew in the following environment construction procedure.
Homebrew Install using the instruction from official website.

1) Install Command Line Tools

To use Homebrew, you need to install Command Line Tools for Xcode.

When you execute the following command from the terminal, the installation confirmation dialog is displayed.
Click the install button.

xcode-select --install

2) Install Homebrew

Install it by running the following command:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

3) Installation confirmation

Run the following command.

brew --version

If you see the following, you’re okay.
(Latest version 2020-09-06: 2.4.16)

Homebrew 2.4.16
Homebrew/homebrew-core (git revision 7ec07; last commit 2020-09-06)
Homebrew/homebrew-cask (git revision f373b; last commit 2020-09-06)

If the version is old, update it with the following command.

brew update

II. Java environment installation

Scala runs on the Java platform (Java Virtual Machine), so a JVM must be installed. Also, use Amazon Corretto 8 on Mac and Windows as the JDK to use.

Mac

1) Download pkg file

Download “amazon-corretto-preview2-8u192-macosx-x64.pkg” from the following site.
https://docs.aws.amazon.com/ja_jp/corretto/latest/corretto-8-ug/downloads-list.html

2) Installation

Double-click the downloaded pkg file and install it according to the installation procedure.

3) Setting environment variables

Config the following settings in .bash_profile, .zshrc, etc.

export JAVA_HOME=/Library/Java/JavaVirtualMachines/amazon-corretto-8.jdk/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH

*The path set in JAVA_HOME can be obtained from this command.

 /usr/libexec/java_home

4) Installation confirmation

Execute the following command in CLI terminal.

java -version

If you see the following, you are successful.
(Latest version as of January 8, 2019: 1.8.0_192)

openjdk version "1.8.0_192"
OpenJDK Runtime Environment (build 1.8.0_192-amazon-corretto-preview2-b12)
OpenJDK 64-Bit Server VM (build 25.192-b12, mixed mode)

III.IntelliJ environment

IntelliJ is an integrated development environment that supports multiple languages ​​such as Java.
It is also the base of Android Studio, which is famous as an Android development environment.

Install IntelliJ

1) Download

Mac

Click “DOWNLOAD” for the Community edition from this site to download the .dmg file.
Download

Download IntelliJ

Windows

Click “DOWNLOAD” for Community edition from this site to download the .exe file.
Download

Linux

Click “DOWNLOAD” for the Community edition from this site to download the .tar.gz file.
Download

2) Install

Mac

Open the .dmg package and drag and drop IntelliJ IDEA into your application folder

Windows

Launch the .exe file and follow the installation wizard

Linux

Extract the .tar.gz file and run bin / idea.sh.

./idea.sh

3) IntelliJ configuration

Start IntelliJ.
The following dialog will be displayed. Select [Do not import …] and click [OK].

Check [I confirm …] and click [Continue].

The following screen will appear Select your favorite design and click
[Next: Keymaps]

Click [Next: Launcher Script]
3.png

Click [Next: Default plugins]

Click [Next: Featured plugins]

Click Install in Scala to install the Scala plugin. Finally, click [Start using Intellij IDEA] to complete.

IV. Install sbt

What is sbt?

sbt is a build tool for Scala.
You will need it to create and build Playframework projects.

1) Install sbt

Mac

brew install sbt

Windows

Download [sbt-1.2.8.msi] from the following site and double-click to install it.

Download

Linux

Follow the steps on this site to install.

Install

5. Create Project

1) Move to the directory where you want to place the project

Change to the appropriate directory where you want to place the project files.

cd 

2) Create a new project

sbt new playframework/play-scala-seed.g8

This template generates a Play Scala project 

name [play-scala-seed]: 

Enter “sample-play-scala” here.

Then continue with default

This template generates a Play Scala project

name [play-scala-seed]: sample-play-scala
organization [com.example]:

Template applied in ./sample-play-scala

On Windows, you may get the following error, but you can safely ignore it.

[error] java.io.IOException: Unable to delete file: \AppData\Local\Temp\giter8-86279809762767\src\main\g8\.gitignore
[error] Use 'last' for the full log.

3) Confirm that the project has been created

It’s okay if the directory where you executed the command has a “sample-play-scala” directory.

6. Import project

1)Click Import Project

2) Select the root directory of the project created above.

3) Select [Import project from external model] and SBT and click the [Next] button.

スクリーンショット 2019-01-09 12.38.50.png

4) Import settings

Click the [New …] button in the [Project JDK]

スクリーンショット 2019-01-09 12.41.20.png

5) Select [JDK] in the next dialog.

6) The directory selection dialog is displayed. Select the Java installed above.

Mac

/Library/Java/JavaVirtualMachines/amazon-corretto-8.jdk/Contents/Home

Windows

C:\Program Files\Amazon Corretto\jdk1.8.0_192

Linux

/usr/lib/jvm/java-8-openjdk-amd64

7) Sync will start. When Sync is complete, everything is ready.

Make sure the scaffolding project working by showing up “Welcome to Play!” in browser after run below command in project dir

cd sample-play-scala
sbt run

Source
https://github.com/ddnb/sample-play-scala/releases/tag/v1.0.0