Incorrect command line arguments parsing in gradlew under TCC/4NT


(Matias Hernandez) #1

For some reason, the default gradlew.bat file for Windows includes these lines:

goto execute

@rem Get arguments from the 4NT Shell from JP Software

The problem is that using %$ actually causes problems with command-line arguments in TCC/4NT, in particular when they include dashes. For example, trying to run the following:

gradlew :Dashboard:assembleRelease --daemon --parallel -Dorg.gradle.jvmargs=-Xmx2048m

produces the error

Problem configuring task :Dashboard:assembleRelease from command line.
> Unknown command-line option '-X'.

This happens because %$ is breaking the last argument into two separate ones. Indeed, printing the value of %CMD_LINE_ARGS% yields

:Dashboard:assembleRelease --daemon --parallel -Dorg.gradle.jvmargs -Xmx2048m

whereas %* does not produce this problem.

According to the TCC documentation, the only difference between %$ and %* is in respect to the SHIFT command, which is not used anywhere in gradlew.bat that I can see. So maybe it’s not actually necessary to handle TCC/4NT in any special way? Indeed, removing these lines fixes the issue, with no apparent ill effects.

Is the “official” gradlew.bat file the one at I was thinking of sending a pull request removing this, if you believe it would be correct.

Gradle Version: Any
Operating System: Windows 10 with TCC/LE 13.06.77
Is this a regression? Apparently no

(Sterling Greene) #2

Thanks. I raised GRADLE-3476

I think this is just a remnant of where the script originally came from (it used to use shift). Feel free to submit a PR.

The file lives here:

gradlew.bat is generated from that file.

(Marco Vermeulen) #3

Thanks again for contributing, your pull request was merged and should make it into an upcoming milestone release for Gradle 3.0.