-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
9 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,31 @@ | ||
+++ | ||
title = 'Call Gradle Wrapper from nested Directory' | ||
date = 2021-10-29T20:24:48+01:00 | ||
draft = true | ||
+++ | ||
|
||
Save this script as `gw`, make it executable and put it to the search path: | ||
The following script will allow you to use `gw` instead of `./gradlew` in any subdirectory. `gw` will go up the directory hierarchy until it finds `gradlew` or a gradle settings file. | ||
<!--more--> | ||
|
||
Save this script as `gw`, make it executable and add it to the search path: | ||
|
||
``` | ||
#!/bin/bash | ||
relative_path='.' | ||
while [[ $(realpath $relative_path) != '/' ]]; do | ||
#echo $(realpath $relative_path) | ||
if [[ -f "${relative_path}/gradlew" ]]; then | ||
#echo "Found gradlew at ${relative_path}" | ||
# Found gradlew, execute it. | ||
${relative_path}/gradlew "$@" | ||
break | ||
fi | ||
# Check for Gradle settings files. | ||
if [[ -f "${relative_path}/settings.gradle" || -f "${relative_path}/settings.kts" || -f "${relative_path}/settings.gradle.kts" ]]; then | ||
# Found a Gradle settings file, stop searching. | ||
break | ||
fi | ||
# Move up one directory. | ||
relative_path="${relative_path}/.." | ||
done | ||
``` | ||
|
||
This will allow you to use `gw` instead of `./gradlew` in any subdirectory. `gw` will search up until it finds `gradlew` or a gradle settings file. | ||
|