Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions java/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Maven build output
target/
2 changes: 2 additions & 0 deletions java/.tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
java corretto-21
maven 3
22 changes: 21 additions & 1 deletion java/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,30 @@

Skeleton project for Java using Maven.

## Toolchain

The toolchain is declared in [`.tool-versions`](.tool-versions):

```
java corretto-21
maven 3
```

Install it however you prefer — [mise](https://mise.jdx.dev) is the easiest route:

```bash
mise install
```

`./script/setup` does not install the toolchain; it expects the tools above to be on your `PATH`.

## Usage

Feel free to run the main class and test suites directly through your IDE of choice. If you want to run from the terminal, you can use these commands:

- `./script/setup` to attempt to install required packages (Java and Maven)
- `./script/setup` to download dependencies
- `./script/run` to run the main class
- `./script/test` to run the test suite

The example test passes out of the box. A good way to get your bearings is to break it
deliberately, watch it fail, then put it back.
8 changes: 6 additions & 2 deletions java/script/run
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#!/bin/bash
#!/usr/bin/env bash

mvn exec:java
set -euo pipefail

cd "$(dirname "${BASH_SOURCE[0]}")/.."

mvn --quiet exec:java
12 changes: 5 additions & 7 deletions java/script/setup
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/bin/bash
#!/usr/bin/env bash

set -e
set -euo pipefail

if which brew >/dev/null 2>&1 ; then
brew install maven
else
echo "You don't have brew installed, so we can't automatically install Java and Maven. Please install them yourself."
fi
cd "$(dirname "${BASH_SOURCE[0]}")/.."

mvn --quiet dependency:resolve
8 changes: 6 additions & 2 deletions java/script/test
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#!/bin/bash
#!/usr/bin/env bash

mvn test
set -euo pipefail

cd "$(dirname "${BASH_SOURCE[0]}")/.."

mvn test
Loading