2022-12-08 20:25:43 -08:00
|
|
|
#!/usr/bin/env bash
|
2023-04-11 20:26:25 -07:00
|
|
|
# @file SDKMAN Install
|
|
|
|
# @brief Ensures SDKMAN is installed.
|
|
|
|
# @description
|
|
|
|
# This script ensures SDKMAN (a Java version manager) is installed using the method recommended on [their
|
|
|
|
# website](https://sdkman.io/).
|
2022-12-08 20:25:43 -08:00
|
|
|
|
2022-12-25 00:30:40 -08:00
|
|
|
{{ includeTemplate "universal/profile" }}
|
|
|
|
{{ includeTemplate "universal/logg" }}
|
2022-12-08 20:25:43 -08:00
|
|
|
|
2023-08-03 23:05:20 -07:00
|
|
|
### SDKMan ~/.bashrc settings
|
|
|
|
if command -v brew > /dev/null && command -v sdkman-cli > /dev/null; then
|
|
|
|
export SDKMAN_DIR="$(brew --prefix sdkman-cli)/libexec"
|
|
|
|
. "$SDKMAN_DIR/bin/sdkman-init.sh"
|
|
|
|
elif [ -f "$SDKMAN_DIR/bin/sdkman-init.sh" ]; then
|
2023-08-07 22:29:21 -07:00
|
|
|
export SDKMAN_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/sdkman"
|
2023-08-03 23:05:20 -07:00
|
|
|
. "$SDKMAN_DIR/bin/sdkman-init.sh"
|
|
|
|
fi
|
|
|
|
|
2022-12-08 20:25:43 -08:00
|
|
|
### Ensure SDKMan is installed (https://sdkman.io/)
|
|
|
|
if [ ! -d "$SDKMAN_DIR" ]; then
|
2023-11-04 18:46:18 -07:00
|
|
|
logg info 'Installing SDKMan via curl -s "https://get.sdkman.io?rcupdate=false'
|
2022-12-08 20:25:43 -08:00
|
|
|
logg info "Install directory: $SDKMAN_DIR"
|
2023-02-01 18:18:06 -08:00
|
|
|
curl -s "https://get.sdkman.io?rcupdate=false" | bash
|
2023-11-04 18:46:18 -07:00
|
|
|
logg info 'Running sdk install java with bash -c'
|
2023-06-13 23:40:48 -07:00
|
|
|
bash -c 'sdk install java'
|
2022-12-08 20:25:43 -08:00
|
|
|
else
|
|
|
|
logg info 'SDKMan appears to already be installed.'
|
2023-11-04 18:46:18 -07:00
|
|
|
logg info 'Running sdk update'
|
2023-07-07 01:29:58 -07:00
|
|
|
sdk update
|
2022-12-08 20:25:43 -08:00
|
|
|
fi
|