How to use SDKMAN! to install packages from within scripts
you need to source in ~/.sdkman/bin/sdkman-init.sh, like in
#!/bin/bash
. /home/alexw/.sdkman/bin/sdkman-init.sh
sdk install java 8u144-zulu
'sdk' is a bash function declared in sdkman-init.sh, and your first line (#!...) starts a new(!) shell.
hope that helps! weHe
Here's how to source sdkman-init.sh
more generically:
source "$HOME/.sdkman/bin/sdkman-init.sh"
This is similar to the code that SDKMAN adds to your .zshrc
file:
#THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!!
export SDKMAN_DIR="/Users/powers/.sdkman"
[[ -s "/Users/powers/.sdkman/bin/sdkman-init.sh" ]] && source "/Users/powers/.sdkman/bin/sdkman-init.sh"
Type which sdk
if you'd like to see the function that's being sourced:
sdk () {
COMMAND="$1"
QUALIFIER="$2"
case "$COMMAND" in
(l) COMMAND="list" ;;
(ls) COMMAND="list" ;;
(v) COMMAND="version" ;;
(u) COMMAND="use" ;;
...
...