Skip to content

Commit 008cafe

Browse files
adamnfish-guCopilot
andcommitted
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>
1 parent aa2898d commit 008cafe

6 files changed

Lines changed: 35 additions & 30 deletions

File tree

‎scala/.gitignore‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1+
# sbt build output
2+
target/
3+
14
# Metals / builds
25
.bloop
36
.bsp
47
metals.sbt
5-
6-
# Temp install of sbt
7-
sbt/
8-
*.zip

‎scala/.tool-versions‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
java corretto-21
2+
sbt 1

‎scala/README.md‎

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,26 @@
22

33
Skeleton project for Scala.
44

5+
## Prerequisites
6+
7+
The toolchain this project needs is declared in [`.tool-versions`](./.tool-versions):
8+
9+
```
10+
java corretto-21
11+
sbt 1
12+
```
13+
14+
Install those however you prefer, as long as they end up on your `PATH`. The quickest route is
15+
[mise](https://mise.jdx.dev/), which reads the file for you:
16+
17+
```sh
18+
mise install
19+
```
20+
521
## Usage
6-
- `./script/setup` to install dependencies
7-
- `./script/test` to run the tests
8-
9-
## Usage (on Windows)
10-
- Make sure JDK version 8 or above is installed and JAVA_HOME environment variable is set
11-
- Use Powershell to execute the below commands
12-
- `PowerShell.exe -ExecutionPolicy UnRestricted -File .\script\setup.ps1` to download and extract portable sbt
13-
- (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)
14-
- `.\sbt\sbt\bin\sbt test` to run tests
22+
- `./script/setup` to fetch dependencies
23+
- `./script/test` to run the tests, or `./script/test --watch` to re-run them on every change
24+
- `./script/start` to run the app
1525

1626
## Structure
1727
- Code located in [`Main.scala`](./src/main/scala/gu/com/Main.scala)

‎scala/script/setup‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env bash
22

3-
set -e
3+
set -euo pipefail
44

5-
brew install --cask "guardian/devtools/gu-scala"
5+
cd "$(dirname "${BASH_SOURCE[0]}")/.."
6+
7+
sbt update

‎scala/script/setup.ps1‎

Lines changed: 0 additions & 15 deletions
This file was deleted.

‎scala/script/start‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
cd "$(dirname "${BASH_SOURCE[0]}")/.."
6+
7+
sbt run

0 commit comments

Comments
 (0)