Last active
August 16, 2018 00:35
-
-
Save jwu910/f37272ce482976b0a5bcddc1d5ecbaa2 to your computer and use it in GitHub Desktop.
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
# Get project root path | |
function rootLevel { | |
git rev-parse --show-toplevel 2>/dev/null | |
} | |
# Liferay run-gradle script to find gradle files in parent directories for portlet deployment | |
function rungradle { | |
local current_dir=$(pwd) | |
# Rename settings.gradle temporarily | |
if [ -e settings.gradle ]; then | |
mv settings.gradle settings.gradle.tmp | |
fi | |
# Run regular gradle commands | |
local root_level=$(rootLevel) | |
local parent_dir=$(dirname -- "$root_level") | |
# Check if project is an osb sub repo, if so, get new root_level from parent_dir | |
if [[ "$root_level" = *"osb-"* ]]; then | |
cd "$parent_dir" | |
root_level=$(rootLevel) | |
cd "$current_dir" | |
fi | |
if [[ -n "$root_level" && -f "$root_level/gradlew" ]]; then | |
root_level="$root_level/gradlew" | |
else | |
root_level=$(which gradle) | |
fi | |
# Execute arguments as gradle commands | |
"$root_level" $@ | |
if [ -e settings.gradle.tmp ]; then | |
mv settings.gradle.tmp settings.gradle | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment