From 008cafed82617d85d08ffce3e1e32292849f86ef Mon Sep 17 00:00:00 2001 From: Adam Fisher Date: Tue, 4 Aug 2026 14:16:11 +0000 Subject: [PATCH] Declare the scala toolchain in .tool-versions script/setup ran `brew install --cask guardian/devtools/gu-scala`, which is macOS-only and installs tools system-wide. It now runs `sbt update` to fetch dependencies. Removes the Windows-only setup.ps1. mise covers Windows. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- scala/.gitignore | 7 +++---- scala/.tool-versions | 2 ++ scala/README.md | 28 +++++++++++++++++++--------- scala/script/setup | 6 ++++-- scala/script/setup.ps1 | 15 --------------- scala/script/start | 7 +++++++ 6 files changed, 35 insertions(+), 30 deletions(-) create mode 100644 scala/.tool-versions delete mode 100644 scala/script/setup.ps1 create mode 100755 scala/script/start diff --git a/scala/.gitignore b/scala/.gitignore index c23b464..8ad4160 100644 --- a/scala/.gitignore +++ b/scala/.gitignore @@ -1,8 +1,7 @@ +# sbt build output +target/ + # Metals / builds .bloop .bsp metals.sbt - -# Temp install of sbt -sbt/ -*.zip \ No newline at end of file diff --git a/scala/.tool-versions b/scala/.tool-versions new file mode 100644 index 0000000..e48fa7b --- /dev/null +++ b/scala/.tool-versions @@ -0,0 +1,2 @@ +java corretto-21 +sbt 1 diff --git a/scala/README.md b/scala/README.md index 4a04563..9de01f5 100644 --- a/scala/README.md +++ b/scala/README.md @@ -2,16 +2,26 @@ Skeleton project for Scala. +## Prerequisites + +The toolchain this project needs is declared in [`.tool-versions`](./.tool-versions): + +``` +java corretto-21 +sbt 1 +``` + +Install those however you prefer, as long as they end up on your `PATH`. The quickest route is +[mise](https://mise.jdx.dev/), which reads the file for you: + +```sh +mise install +``` + ## Usage -- `./script/setup` to install dependencies -- `./script/test` to run the tests - -## Usage (on Windows) -- Make sure JDK version 8 or above is installed and JAVA_HOME environment variable is set -- Use Powershell to execute the below commands -- `PowerShell.exe -ExecutionPolicy UnRestricted -File .\script\setup.ps1` to download and extract portable sbt - - (If this script fails you can do this manually by visiting https://github.com/sbt/sbt/releases ,downloading the latest sbt zip and extracting it to ./coding-exercise-project/scala/sbt) -- `.\sbt\sbt\bin\sbt test` to run tests +- `./script/setup` to fetch dependencies +- `./script/test` to run the tests, or `./script/test --watch` to re-run them on every change +- `./script/start` to run the app ## Structure - Code located in [`Main.scala`](./src/main/scala/gu/com/Main.scala) diff --git a/scala/script/setup b/scala/script/setup index 0cf0b02..3042a15 100755 --- a/scala/script/setup +++ b/scala/script/setup @@ -1,5 +1,7 @@ #!/usr/bin/env bash -set -e +set -euo pipefail -brew install --cask "guardian/devtools/gu-scala" +cd "$(dirname "${BASH_SOURCE[0]}")/.." + +sbt update diff --git a/scala/script/setup.ps1 b/scala/script/setup.ps1 deleted file mode 100644 index 7edf805..0000000 --- a/scala/script/setup.ps1 +++ /dev/null @@ -1,15 +0,0 @@ - - -$url = "https://github.com/sbt/sbt/releases/download/v1.9.1/sbt-1.9.1.zip" -$zipFilename = "./sbt-1.9.1.zip" -$localSbt = "./sbt" - -# Download SBT Zip -Import-Module BitsTransfer -Start-BitsTransfer -Source $url -Destination $zipFilename - -# Unzip to temp folder -Expand-Archive -Force -LiteralPath ./$zipFilename -DestinationPath $localSbt - -# Add to temp PATH -$env:PATH += ";" + (Convert-Path "$localSbt/sbt/bin" ) + ";" diff --git a/scala/script/start b/scala/script/start new file mode 100755 index 0000000..1653071 --- /dev/null +++ b/scala/script/start @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -euo pipefail + +cd "$(dirname "${BASH_SOURCE[0]}")/.." + +sbt run