Gradle wrapper which takes care of the required java version (wraps gradlew
, gradlew.bat
, gradle
command)
I always
get the stupid
error Unsupported class file major version XX
even when I define sourceCompatibility
or targetCompatibility
or JavaLanguageVersion.of
in my build.gradle*
file! That's cause gradle does
not take care of the java version. This script will change that now
- Download the and add
gw
sh script to your repository (next to yourgradlew
)
- Download the
gw
sh script to your home folder (~
) - Add this line
alias gw=~/gw
to your bash profile or .zshrc, ...
cd my_repo
ls -1
> gw
> build.gradle
> gradlew
> gradle.bat
cat build.gradle | grep sourceCompatibility
> sourceCompatibility = JavaVersion.VERSION_1_8
echo $JAVA_HOME
> /Library/Java/JavaVirtualMachines/graalvm-ce-java17-22.1.0/Contents/Home
gw --version
> ------------------------------------------------------------
> Gradle 6.8.3
> ------------------------------------------------------------
> JVM: 1.8.0_312 (Azul Systems, Inc. 25.312-b07)
- Auto update: the
gw
sh script will update itself as long as env is notGW_UPDATE="false"
- Auto Detect command
gradlew
,gradlew.bat
or fallback togradle
command - Auto Detect Java from
sourceCompatibility
ortargetCompatibility
inbuild.gradle*
- Debug mode with one of the gradle parameters:
-d
-w
-s
-S
- The script is NOT tested on
windows
orcygwin
sourceCompatibility
ortargetCompatibility
is needed inbuild.gradle*
but the script cant resolve variables- workaround: call the version variable like the java version e.g.
sourceCompatibility = JavaVersion.VERSION_1_8
- workaround: call the version variable like the java version e.g.
- It's not installing any java versions for you
- Use your IDE to download the right java version