|
1 |
| -gdub |
2 |
| -==== |
| 1 | +# What's gdub? |
| 2 | + |
| 3 | +gdub (`gw` on the command line) is a gradlew / gradle wrapper. This is not to be confused with the [Gradle |
| 4 | +Wrapper](http://www.gradle.org/). gdub actually uses the Gradle Wrapper on |
| 5 | +projects where one is configured, but falls back to use the system-installed |
| 6 | +Gradle if a wrapper is not availble. |
| 7 | + |
| 8 | +## The problems with gradle and gradlew |
| 9 | + |
| 10 | +gdub is a convienence for developers running local gradle commands and addresses |
| 11 | +a few minor shortcomings of gradle and gradlew's commandline behaviour: |
| 12 | + |
| 13 | +### You have to provide a relative path to `build.gradle` |
| 14 | + |
| 15 | +If you are using the `gradle` command, you have to provide gradle the path to |
| 16 | +the `build.gradle` file you want to run. If you happen to be in a directory |
| 17 | +other than the root of your project, this can be somewhat cumbersome: |
| 18 | + |
| 19 | + ~/myProject/src/main/java/org/project/stuff$ gradle -b ../../../../../../build.gradle build |
| 20 | + |
| 21 | +With `gw`, this becomes: |
| 22 | + |
| 23 | + ~/myProject/src/main/java/org/project/stuff$ gw build |
| 24 | + |
| 25 | +### You have to provide a relative path to `gradlew` |
| 26 | + |
| 27 | +If you are using `gradlew` and you want to run your build, you need to do |
| 28 | +something similiar and provide the relative path to the `gradlew` script: |
| 29 | + |
| 30 | + ~/myProject/src/main/java/org/project/stuff$ ../../../../../../gradlew build |
| 31 | + |
| 32 | +Again, with `gw` this becomes: |
| 33 | + |
| 34 | + ~/myProject/src/main/java/org/project/stuff$ gw build |
| 35 | + |
| 36 | +### You have a combination of the above problems |
| 37 | + |
| 38 | +I don't even want to type out an example of this, let alone do it on a |
| 39 | +day-to-day basis. Use your imagination. |
| 40 | + |
| 41 | +### Typing `./gradlew` to run the gradle wrapper is kind of inconvenient |
| 42 | + |
| 43 | +Even with tab completion and sitting at the root of your project, you have to |
| 44 | +type at least `./gr<tab>`. It gets a bit worse if you happen to have a |
| 45 | +`gradle.properties` file, and with the gradle wrapper, you have a `gradle` |
| 46 | +directory to contend with as well. A simple alias would solve this problem, but |
| 47 | +you still have the other (more annoying) issues to contend with. |
| 48 | + |
| 49 | +## The `gw` payoff |
| 50 | + |
| 51 | +Anywhere you happen to be on your project, you can run the gradle tasks of your |
| 52 | +project by typing `gw <tasks>`, regardless of whether you use the Gradle Wrapper |
| 53 | +in your project or not. |
| 54 | + |
| 55 | +`gw` works by looking upward from your current directory and will run the |
| 56 | +nearest `build.gradle` file with the nearest `gradlew` |
| 57 | + |
| 58 | +# Installing gdub from source |
| 59 | + |
| 60 | +You will probably want to install [Gradle](http://www.gradle.org) first. While |
| 61 | +this is not technically necessary if all your projects are using a Gradle |
| 62 | +Wrapper, it is a good idea to have Gradle available system-wide because some |
| 63 | +handy Gradle features are available outside the context of an existing project. |
| 64 | + |
| 65 | +Check out a copy of the gdub repository. Then, either add the gdub `bin` |
| 66 | +directory to your `$PATH`, or run the provided `install` command with the |
| 67 | +location to the prefix in which you want to install gdub. |
| 68 | + |
| 69 | +For example, to install gdub into `/usr/local`: |
| 70 | + |
| 71 | + $ git clone https://github.com/ReadyTalk/gdub.git |
| 72 | + $ cd gdub |
| 73 | + $ ./install /usr/local |
| 74 | + |
| 75 | +Note that you may need to run `install` with `sudo` if you do not have |
| 76 | +permission to write to the installation prefix. |
3 | 77 |
|
4 |
| -A gradlew / gradle wrapper. |
|
0 commit comments