gdub

A gradlew / gradle wrapper.
授权协议 MIT License
开发语言 SHELL
所属分类 应用工具、 终端/远程登录
软件类型 开源软件
地区 不详
投 递 者 锺离刚洁
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

This project is obsolete. Please use 'gng' instead. Visit at gng

What's gdub?

gdub (gw on the command line) is a gradle / gradlew wrapper. Not to beconfused with the Gradle Wrapper, gw invokes ./gradlew onprojects where one is configured, and falls back to use the gradle from the$PATH if a wrapper is not available. Also, gw is 66% shorter to type than gradleand 78% shorter to type than ./gradlew.

Installation

There are now a few ways to install gdub, with more on the way. Use whichever ismost convenient for you or feel free to suggest another!

Homebrew

If you are on OSX and not using homebrew, I'm not quite sure what to do withyou. Install gdub with homebrew like so:

brew install gdub

MacPorts

If you use MacPorts, you can install gdub like so:

sudo port install gdub

bpkg

If you use bpkg, you may install like so:

bpkg install dougborg/gdub -g

Installing gdub from source

You will probably want to install Gradle first. While this is nottechnically necessary if all your projects are using a Gradle Wrapper, it is agood idea to have the latest version of gradle available system-wide becausesome handy Gradle features are available outside the context of an existingproject.

Check out a copy of the gdub repository. Then, either add the gdub bindirectory to your $PATH, or run the provided install command with thelocation to the prefix in which you want to install gdub. The default prefix is/usr/local.

For example, to install gdub into /usr/local/bin:

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

Note: you may need to run ./install with sudo if you do not havepermission to write to the installation prefix.

Aliasing the gradle command

For maximum fidelity add a gradle alias to gw to your shell's configurationfile.

Example bash:

echo "alias gradle=gw" >> ~/.bashrc
source ~/.bashrc

From now on you can just type gradle ... from wherever you are and gw takescare of the rest. Happiness ensues!

Why gdub?

The problems with gradle and gradlew

gdub is a convenience for developers running local Gradle commands and addressesa few minor shortcomings of gradle and gradlew's commandline behaviour.These are known issues, and they are set to be addressed in future versions ofGradle. If you are interested in the discussions surrounding them, check out:

Here are the issues I feel are most important, and the ones gdub attempts toaddress:

You have to provide a relative path to build.Gradle

If you are using the gradle command, and you are not in the same directory asthe build.gradle file you want to run, you have to provide gradle the path.Depending on where you happen to be, this can be somewhat cumbersome:

$ pwd
~/myProject/src/main/java/org/project
$ gradle -b ../../../../../build.gradle build

With gw, this becomes:

$ gw build

You have to provide a relative path to gradlew

If you are using gradlew and you want to run your build, you need to dosomething similiar and provide the relative path to the gradlew script:

$ pwd
~/myProject/src/main/java/org/project/stuff
$ ../../../../../../gradlew build

Again, with gw this becomes:

$ gw build

You have a combination of the above problems

I don't even want to type out an example of this, let alone do it on aday-to-day basis. Use your imagination.

Typing ./gradlew to run the Gradle wrapper is kind of inconvenient

Even with tab completion and sitting at the root of your project, you have totype at least ./gr<tab>. It gets a bit worse if you happen to have aGradle.properties file, and with the Gradle wrapper, you have a gradledirectory to contend with as well. A simple alias would solve this problem, butyou still have the other (more annoying) issues to contend with.

You meant to use the project's gradlew, but typed gradle instead

This can be a problem if the project you are building has customizations to theGradle wrapper or for some reason is only compatible with a certain version ofGradle that is configured in the wrapper. If you know the project uses Gradle,you may be tempted to just use your own system's Gradle binary. This might beok, or it might cause the build to break, but if a project has a gradlew, itis a pretty safe bet you should use it, and not whatever Gradle distribution youhappen to have installed on your system.

The gw payoff

Anywhere you happen to be on your project, you can run the Gradle tasks of yourproject by typing gw <tasks>, regardless of whether you use the Gradle Wrapperin your project or not.

gw works by looking upwards from your current directory and will run thenearest build.Gradle file with the nearest gradlew. If a gradlew cannotbe found, it will run the nearest build.Gradle with your system's Gradle. Thisis probably always what you want to do if you are running Gradle from within aproject's tree that uses the Gradle build system.

相关阅读

相关文章

相关问答

相关文档