Inconsistent handling of -g and -Dgradle.user.home on the command line?

I found an inconsistency in handling of the -Dgradle.user.home property and the -g switch when used on the command line. I am using gradle wrapper. I have the $HOME/.gradle/wrapper/dists/gradle-1.6-bin/… directory, so that the wrapper doesn’t have to be downloaded again when invoked normally.

Now, when in project root directory: 1. when I invoke ./gradlew -g /home/wujek/gradle_home the wrapper is not downloaded, although the new home directory is empty, and the one from $HOME/.gradle is used 2. when I invoke ./gradlew -Dgradle.user.home=/home/wujek/gradle_home (with the new home directory empty again), this time the wrapper is downloaded to the new directory

I think #1 is incorrect handling of the -g switch, and #2 is correct. Anyways, these two are inconsistent although I would expect them to be. Am I wrong in assuming these should be handled identically (i.e., using -g new_home should also download the wrapper to new_home)?

I noticed this behavior trying to configure the Jenking Gradle Plugin to use the wrapper and setting the gradle home directory (there is a bug in the latest plugin version 1.22 that sets the gradle dir to be always within the job workspace, which most people don’t want and want to override, because it causes the wrapper and the artifacts to be downloaded for each job and other issues - https://issues.jenkins-ci.org/browse/JENKINS-17386). I noticed that even though I used the -g switch the wrapper was still downloaded. With -Dgradle.user.home it happens only once, for the first project.

Is this inconsistent handling of -g vs -Dgradle.user.home by desing? If so, why?

wujek

Closing this one off as you raised another post.