I am working on switching our gradle build to using the gradle wrapper. The problem I see is that I cannot call the gradlew script from any other directory but where it is "installed", since it is not on the PATH
.
I have found a few batch/unix scripts that may or may not solve the problem, but as I am running windows they don't really help much.
Not being able to find any solution for windows on the wide internet, I created my own little batch script. Just make sure it is available on the PATH
.
I have named my script g.bat, which allows me to just type g build
to build something.
@echo off
set REL_PATH=.\
set ABS_PATH=%CD%
rem echo %ABS_PATH%\gradlew.bat
: check
set GRADLE_WRAPPER=%ABS_PATH%\gradlew.bat
IF NOT EXIST %GRADLE_WRAPPER% goto up
rem echo %GRADLE_WRAPPER%
goto success
: up
IF %ABS_PATH%==%CD:~0,3% goto fail
set REL_PATH=%REL_PATH%..\
pushd %REL_PATH%
set ABS_PATH=%CD%
popd
goto check
:fail
echo Could not find gradlew.bat
goto end
:success
call %GRADLE_WRAPPER% %*
: end