---
title: How to run Gradle wrapper from any subdir with Gdub
description: "Gradle is a popular and flexible build system for JVM-based languages. We use Gradle as the build system for Mesos Elasticsearch. In this blog I discuss two Gradle concepts: the Gradle wrapper and Gdub, a tool that allows you to run the Gradle wrapper from any subdirectory."
image: http://cdn2.hubspot.net/hubfs/2668666/All-InOne-2016/Image/bg-img.jpg
---

Check out our **[Cloud Native Services](https://www.container-solutions.com/services) **and** **book a call with one of our experts today! 

[![Container Solutions](https://blog.container-solutions.com/hubfs/CS_blog/logo-main.svg "Container Solutions")](http://container-solutions.com)

- share:
- [**](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fblog.container-solutions.com%2Fhow-to-run-gradle-wrapper-from-any-subdir-with-gdub)
- [**](https://www.twitter.com/share?url=https%3A%2F%2Fblog.container-solutions.com%2Fhow-to-run-gradle-wrapper-from-any-subdir-with-gdub)
- [**](http://www.linkedin.com/shareArticle?mini=true&url=https://blog.container-solutions.com/how-to-run-gradle-wrapper-from-any-subdir-with-gdub)
- [**](https://blog.container-solutions.com/how-to-run-gradle-wrapper-from-any-subdir-with-gdub#)

[![](http://cdn2.hubspot.net/hubfs/2668666/All-InOne-2016/Image/bg-img.jpg) ](https://blog.container-solutions.com/how-to-run-gradle-wrapper-from-any-subdir-with-gdub)

[Microservices](https://blog.container-solutions.com/tag/microservices)

# How to run Gradle wrapper from any subdir with Gdub

[Frank Scholten](https://blog.container-solutions.com/author/frank-scholten)

![Frank Scholten](https://blog.container-solutions.com/hubfs/frank.jpg)

 May 22, 2015

 3 minutes Read

[![How to run Gradle wrapper from any subdir with Gdub](https://blog.container-solutions.com/hs-fs/hubfs/Imported_Blog_Media/gradle1-1.jpeg?width=100&name=gradle1-1.jpeg)](https://blog.container-solutions.com/hubfs/Imported_Blog_Media/gradle1-1.jpeg)

Gradle is a popular and flexible build system for JVM-based languages. We use Gradle as the build system for [Mesos Elasticsearch](https://github.com/mesos/elasticsearch). In this blog I discuss two Gradle concepts: the Gradle wrapper and Gdub, a tool that allows you to run the Gradle wrapper from any subdirectory.

### gradlew - The Gradle wrapper

The Gradle wrapper, *gradlew*, is a shell script that downloads a specific Gradle distribution. This way a software project can configure a version of Gradle and everyone who runs *gradlew* will use the version specified in the project. This makes for a portable build. To try it out clone [Mesos Elasticsearch](https://github.com/mesos/elasticsearch) and run

`frank@franktop:~/src/mesos-elasticsearch$ ./gradlew clean build Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar Downloading https://services.gradle.org/distributions/gradle-2.3-all.zip ...`

Now *gradlew* will fetch gradle version 2.3 and install it under *~/.gradle/wrapper/dists* and use that version from then on. Neat! The Gradle wrapper scripts and config can be generated by adding a wrapper task in your *build.gradle* file. For more information on how to do this see the [Official Gradle wrapper documentation](https://docs.gradle.org/current/userguide/gradle_wrapper.html).

### gdub - A Gradle / gradlew wrapper

If you have used *gradlew* for a while you probably recognize the following scenario. You want to run *gradlew* from a subdirectory. This subdirectory could be several levels deep so you have to invoke *gradlew* like this: *../../../gradlew*. It may not sound like a problem but when you use your build system intensively it can become quite annoying. Luckily there is a simple solution...*gdub*! Gdub locates the gradle wrapper in an ancestor directory. Exactly what we want! Install gdub like this:

`git clone https://github.com/dougborg/gdub.git cd gdub ./install`

and run **gw** plus any gradle tasks and off you go!

`frank@franktop:~/src/mesos-elasticsearch/scheduler$ gw clean build Using gradle at '/home/frank/src/mesos-elasticsearch/gradlew' to run buildfile '/home/frank/src/mesos-elasticsearch/scheduler/build.gradle': ...`

For more information on Gdub checkout the [Gdub Github page](https://github.com/dougborg/gdub)

[### It Ain't What You Do, It's The Way That You Do It

](https://blog.container-solutions.com/it-aint-what-you-do-its-the-way-that-you-do-it)

[![prev-arrow](https://cdn2.hubspot.net/hubfs/3842749/Wow%202019/Images/left-arrow.png) Previous article](https://blog.container-solutions.com/it-aint-what-you-do-its-the-way-that-you-do-it)

[ Next article ![next-arrow](https://cdn2.hubspot.net/hubfs/3842749/Wow%202019/Images/right-arrow.png) ](https://blog.container-solutions.com/microservices-objects-similar-benefits-similar-problems)

[

### Microservices and objects: Similar benefits, similar problem...

](https://blog.container-solutions.com/microservices-objects-similar-benefits-similar-problems)

Comments

Leave your Comment

![cs-logo-white](https://blog.container-solutions.com/hs-fs/hubfs/cs-logo-white.png?width=150&height=61&name=cs-logo-white.png "cs-logo-white")

#### **Talk to sales**

[info@container-solutions.com](mailto:info@container-Solutions.com)

#### Stay In Touch

- [**](https://www.linkedin.com/company/container-solutions/)
- [**](https://twitter.com/containersoluti)

© 2024 Container Solutions