Skip to content

Split View: Scala 개발환경 세팅 in Mac

|

Scala 개발환경 세팅 in Mac

Scala 개발환경 세팅방법

Brew 패키지 관리자를 사용하여 coursier 를 다운로드 한다. (Scala의 의존성 관리 툴이다.)

brew install coursier/formulas/coursier

이후 아래 명령어를 통해 setup을 진행하여 PATH에 scala를 등록하고 기본 Libraries를 다운로드한다.

cs setup

원하는 scala version을 download한다.

cs install scala:2.12.15 scalac:2.12.15

~/.zshrc 하단에 에 scala가 설치된 path Export를 추가하고, 터미널을 종료했다가 다시 실행하면 scala 명령어를 터미널에서 실행할 수 있게 된다.

export PATH="$PATH:/Users/<username>/Library/Application Support/Coursier/bin"

Scala REPL 환경 테스트

Scala는 REPL(Read-Eval-Print-Loop) 환경을 제공한다.

$ scala

Welcome to Scala 2.12.15 (OpenJDK 64-Bit Server VM, Java 18.0.1.1).
Type in expressions for evaluation. Or try :help.

scala> val a = 1;
a: Int = 1

scala> print(a)
1
scala>

Setting Up a Scala Development Environment on Mac

Setting Up a Scala Development Environment

Use the Brew package manager to download coursier. (It is a dependency management tool for Scala.)

brew install coursier/formulas/coursier

Then run the following command to proceed with setup, which registers Scala in your PATH and downloads the default libraries.

cs setup

Download the desired Scala version.

cs install scala:2.12.15 scalac:2.12.15

Add the Scala installation path export to the bottom of ~/.zshrc, and after closing and reopening the terminal, you will be able to run the scala command from the terminal.

export PATH="$PATH:/Users/<username>/Library/Application Support/Coursier/bin"

Scala REPL Environment Test

Scala provides a REPL(Read-Eval-Print-Loop) environment.

$ scala

Welcome to Scala 2.12.15 (OpenJDK 64-Bit Server VM, Java 18.0.1.1).
Type in expressions for evaluation. Or try :help.

scala> val a = 1;
a: Int = 1

scala> print(a)
1
scala>

Quiz

Q1: What is the main topic covered in "Setting Up a Scala Development Environment on Mac"?

How to install Scala on Mac

Q2: What are the key takeaways from this article? How to install Scala on Mac

Q3: How can the concepts in this article be applied in practice? Consider the practical examples and patterns discussed throughout the post.