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.
there's a small utility tool written by the gradle community to solve this issue named gdub
. Find further installation at https://github.com/dougborg/gdub
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.