[GRADLE-1871] Parsing bug in org.gradle.wrapper.GradleWrapperMain Created: 26/Oct/11  Updated: 04/Jan/13  Resolved: 07/Nov/11

Status: Resolved
Project: Gradle
Affects Version/s: 1.0-milestone-5
Fix Version/s: 1.0-milestone-6

Type: Bug
Reporter: Blaine Simpson Assignee: Luke Daley
Resolution: Fixed Votes: 1


"gradle" Bourne script and org.gradle.launcher.GradleMain work just fine.

org.gradle.wrapper.GradleWrapperMain.main(), invoked directly or by "gradlew" Bourne script, when given any command line -P switch with no space between the switch and the name=value and with a capital D in the property name, causes the following (completely wrong) message and exception:

Exception in thread "main" org.gradle.cli.CommandLineArgumentException: No argument was provided for command-line option '-D'.
        at org.gradle.cli.CommandLineParser$KnownOptionParserState.onComplete(CommandLineParser.java:414)
        at org.gradle.cli.CommandLineParser.parse(CommandLineParser.java:114)
        at org.gradle.cli.AbstractCommandLineConverter.convert(AbstractCommandLineConverter.java:33)
        at org.gradle.wrapper.GradleWrapperMain.parseSystemPropertiesFromArgs(GradleWrapperMain.java:67)
        at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:46)

Following both work fine:

java -Dorg.gradle.appname=gradlew -classpath /home/blaine/hsqldb/build/gradle/wrapper/gradle-wrapper.jar org.gradle.wrapper.GradleWrapperMain -Pabc=blah
gradlew -Pabc=blah

Works fine even if I add on multiple -P switches and task arguments.

Cause the problem by adding a capital D anywhere in the property name. All of the following cause GradleWrapperMain to barf:

  • -PD=val
  • -PDab=val
  • -PaDb=val
  • -PadB=val

I can find the coding mistake if you like, but I don't have the time to waste if you will ignore my submittal.

Comment by Darren Evenson [ 03/Nov/11 ]

I would add that the capital D can be in either the property name or the value. This command fails with the same error:

gradlew -PtargetEnvironment=DEV serverProject:tomcatDeploy

However this command works:

gradlew -PtargetEnvironment=dEV serverProject:tomcatDeploy

Comment by Blaine Simpson [ 03/Nov/11 ]

Thanks Darren. I thought to test that too, a couple times, but never remembered it when I had a computer before me.

Generated at Wed Jun 30 12:06:36 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.