Skip to content

Instantly share code, notes, and snippets.

@w25r
Created April 26, 2014 16:53
Show Gist options
  • Save w25r/11325011 to your computer and use it in GitHub Desktop.
Save w25r/11325011 to your computer and use it in GitHub Desktop.
gradle and gradlew batch file support
@echo off
:: This is a handy file to put in a common gradle directory, say C:\Program Files\Gradle, and add that directory to the path
:: Then, when you want to change which version of gradle is used by default, you simply update the batch file to point to that version, without
:: needing to update your path variable.
SET GRADLE_DIR="C:\Program Files\Gradle\gradle-1.10"
%GRADLE_DIR%\bin\gradle %*
@echo off
:: This script forces all calls to gradle to go to gradlew by default
echo Assuming you meant to say 'gradlew'
echo Passing command to gradlew
call gradlew %*
@echo off
:: This script is meant to allow you to add 'gradlew' to your path, and it will find the gradlew at the root of the project, and then run it.
:: It is a workaround to the limitation of gradle wrapper in multiproject builds.
:: Original script was found here http://issues.gradle.org/browse/GRADLE-2429
setlocal enabledelayedexpansion
set CURR_PATH=%cd%
set REAL_GRADLEW=%CURR_PATH%\gradlew.bat
:while1
set REAL_GRADLEW=!CURR_PATH!\gradlew.bat
if exist !REAL_GRADLEW! (
goto :found
)
if "%CURR_PATH:~-1%" == ":" (
goto :notfound
)
call :getdir "%CURR_PATH%"
goto :while1
:notfound
echo Unable to find gradlew.bat file upwards in file system
echo Defaulting to 'gradle^^!' if it's in the path
call gradle^^! %*
goto :goodbye
:found
echo Found gradlew at !REAL_GRADLEW!
call "!REAL_GRADLEW!" %*
goto :goodbye
:goodbye
endlocal
goto :EOF
:getdir
set "CURR_PATH=%~dp1"
set "CURR_PATH=%CURR_PATH:~0,-1%"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment