Skip to content

Instantly share code, notes, and snippets.

@vpatryshev
Created January 17, 2024 19:44
Show Gist options
  • Save vpatryshev/3cff9014b081a6aa16a24a27df6bf16c to your computer and use it in GitHub Desktop.
Save vpatryshev/3cff9014b081a6aa16a24a27df6bf16c to your computer and use it in GitHub Desktop.
Find JDKs that will work with your Scala project
#!/bin/bash
Try all available JDKs to find which one works for your Scala and sbt.
clear && printf '\e[3J'
function testWith(){
java=$1
echo Y | sdk install java "$java"
sdk use java "$java"
sbt clean test package 2>$java.log && rm $java.log && return 0 || return 1
}
function testJavas() {
source "$HOME/.sdkman/bin/sdkman-init.sh"
sdk list java > javalist.sdk
separatorFound=false
while read -r line; do
[[ $line == -----* ]] && separatorFound=true && continue
if [[ $separatorFound == true ]]; then
[[ $line == ======* ]] && exit 0
name=`echo "$line" | cut -d '|' -f 6 -`
testWith $name && echo "SUCCESS on $java" || echo "FAILURE on $java"
fi
done < javalist.sdk
}
testJavas | tee try.log
#sbt -Dsbt.scala.version=2.13.12 clean test package
#sbt -Djava.security.manager=allow clean test package
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment