Skip to content

lunduniversity/hello-scala.g8

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 

Repository files navigation

hello-scala.g8

A template for a minimal Scala project with a minimal build file for the advanced sbt build tool.

However, you may prefer to use the simpler scala-cli tool (instead of the more complex sbt used by this template) like so:

scala-cli run hello.scala --scala-version 3

with this code in file hello.scala

@main def myMainProgram = println("Hello Scala 3!")

How to use this template

You need to have Scala tools installed as described in the Preparations section below. Then you can use this template in terminal or within VS Code with Scala (Metals), as follows.

How to use this template in terminal with sbt

Type this in terminal to create a scala project:

sbt new lunduniversity/hello-scala.g8

Wait for a rather long while. After a while the template has been downloaded from github and you are prompted to give a name for your scala project. The output looks something like this:

$ sbt new lunduniversity/hello-scala.g8
[info] Loading settings for project global-plugins from gpg.sbt ...
[info] Loading global plugins from /home/myUser/.sbt/1.0/plugins
[info] Loading project definition from /home/myUser/tmp/project
[info] Loading settings for project tmp from build.sbt ...
[info] Set current project to tmp (in build file:/home/myUser/tmp/)
[info] Set current project to tmp (in build file:/home/myUser/tmp/)

Minimal Scala app with minimal build file 

name [hello]: myProjectName

Template applied in /home/myUser/tmp/./myProjectName
$

Now you can navigate to a folder with the name you gave the project and start sbt and run your Scala app by typing these commands:

cd myProjectName
sbt
run

How to use this template in VS code with metals

  • Click the curly metals m logo in the left bar
  • Click "New Scala Project" under BUILD COMMANDS
  • Scroll down almost to the bottom and select "Custom Enter template manually"
  • Type lunduniversity/hello-scala.g8 and press enter
  • Click on "Ok"
  • Confirm again with Enter
  • Select "Yes" when asked to open in new window
  • In new window, wait for stuff to download and start and then click the button Import when question if import build comes up in the lower right corner.
  • Open the file called main.scala and press run in the "run | debug" field just above the def run line.

Preparations

  1. Install latest OpenJDK LTS version for your platform from adoptium.net

  2. Install the Scala build tool sbt from https://www.scala-sbt.org/download

  3. Install VS code from here: https://code.visualstudio.com/download

  4. From inside VS code install the extension "metals" as described here: https://marketplace.visualstudio.com/items?itemName=scalameta.metals

References

About

A g8 template for a minimal Scala app built using sbt.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages