- Download the raw script:
curl -o ~/.local/bin/gradlew https://gist.githubusercontent.com/mpetuska/86c05e02b2199e5a2f186da0c2c3f2fd/raw/gradlew.sh
- Adjust permissions:
chmod +x ~/.local/bin/gradlew
- (Optional) Make a shortcut:
ln -s ~/.local/bin/gradlew ~/.local/bin/gw
There's also an installation script available:
curl https://gist.githubusercontent.com/mpetuska/86c05e02b2199e5a2f186da0c2c3f2fd/raw/installGW.sh | bash
With this script setup, you can invoke gradle commands from any directory in multi-module project via nearest wrapper. The script supports both, nested and flat module structure.
Here's an example nested project structure
/parent
/moduleA
/moduleB
/moduleC
With the structure above, you can invoke gradlew
or gw
command from any child subdirectory
and automatically target that module's tasks. For instance the following will invoke :moduleA:test
task only from parent's gradlew.
# pwd - /parent/moduleA
gw test
This also works with flat gradfle project structure
/parent
/moduleA
/moduleB
/moduleC