[GRADLE-2361] ")" character in JAVA_OPTS causes escaping problem in `gradle` startup script Created: 25/Jun/12  Updated: 10/Feb/17  Resolved: 10/Feb/17

Status: Resolved
Project: Gradle
Affects Version/s: None
Fix Version/s: None

Type: Bug
Reporter: Gradle Forums Assignee: Unassigned
Resolution: Won't Fix Votes: 0


Hi all,

When the JAVA_OPTS variable in my .bashrc file contains a round closing bracket ")" I get the following error when I try and run Gradle:

/usr/local/java/gradle-1.0/bin/gradle: eval: line 161: syntax error near unexpected token `)'
/usr/local/java/gradle-1.0/bin/gradle: eval: line 161: `splitJvmOpts -Djavax.net.ssl.trustStore=/home/egrant/Documents/Work/jssecacerts -Djavax.net.ssl.trustStorePassword=changeit -Djavax.net.ssl.keyStore=/home/eddgrant_cert.p12 -Djavax.net.ssl.keyStoreType=pkcs12 -Djavax.net.ssl.keyStorePassword=MyPasswordContainsA)Character -Dorg.gradle.daemon=true'

My JAVA_OPTS declaration in my .bashrc file is as follows:

export JAVA_OPTS="-Djavax.net.ssl.trustStore=/home/egrant/Documents/Work/jssecacerts \
-Djavax.net.ssl.trustStorePassword=changeit \
-Djavax.net.ssl.keyStore=/home/eddgrantcert.p12 \
-Djavax.net.ssl.keyStoreType=pkcs12 \

When this happens Gradle seems to sit and cogitate for a few seconds whenever I ask it to do something, even if I'm using the daemon. It does then work correctly and execute the task I have requested but the wait, and the presence of the error, is rather annoying. If I remove the ")" character everything reverts back to normal and Gradle becomes marvellous once again.

Has anyone else encountered this? Any ideas as to a workaround (I'm unable to change my cert password to work around this otherwise that would be a workable temporary workaround).



Version details below:


Gradle 1.0

Gradle build time: Tuesday, June 12, 2012 12:56:21 AM UTC
Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.8.2 compiled on December 20 2010
Ivy: 2.2.0
JVM: 1.6.0_30 (Sun Microsystems Inc. 20.5-b03)
OS: Linux 3.0.0-21-generic amd64

Comment by Gradle Forums [ 25/Jun/12 ]

Have you tried to escape the `)` with a `\`?

Comment by Gradle Forums [ 25/Jun/12 ]

Sorry forgot to mention that, yes I have, it fixes the Gradle issue but it creates another issue in that my cert password seems to become invalid to things that use it such as Maven, which then spurts the following:

Error transferring file: java.security.NoSuchAlgorithmException:
Error constructing implementation (algorithm: Default, provider: SunJSSE, class: com.sun.net.ssl.internal.ssl.DefaultSSLContextImpl):
failed to decrypt safe contents entry: javax.crypto.BadPaddingException:
Given final block not properly padded

This had led me to the conclusion that the \ character wasn't being treated as an escape character but rather as an additional literal \ character. I guess this makes sense since it's a legal character to have in a Java String and isn't a String terminator.

I'm curious to know it would need escaping for Gradle to work?

Comment by Gradle Forums [ 25/Jun/12 ]

If not escaped, bash treats `)` in the `gradle` script as a bash meta character. Maybe it's a problem with that script. I'll open an issue for this. Meanwhile, you can try to set a `GRADLE_OPTS` which does escape the `)`. If that still causes problems due to the unescaped character in `JAVA_OPTS`, you could edit the `gradle` script to no longer consider `JAVA_OPTS`.

Comment by Benjamin Muschko [ 15/Nov/16 ]

As announced on the Gradle blog we are planning to completely migrate issues from JIRA to GitHub.

We intend to prioritize issues that are actionable and impactful while working more closely with the community. Many of our JIRA issues are inactionable or irrelevant. We would like to request your help to ensure we can appropriately prioritize JIRA issues you’ve contributed to.

Please confirm that you still advocate for your JIRA issue before December 10th, 2016 by:

  • Checking that your issues contain requisite context, impact, behaviors, and examples as described in our published guidelines.
  • Leave a comment on the JIRA issue or open a new GitHub issue confirming that the above is complete.

We look forward to collaborating with you more closely on GitHub. Thank you for your contribution to Gradle!

Comment by Benjamin Muschko [ 10/Feb/17 ]

Thanks again for reporting this issue. We haven't heard back from you after our inquiry from November 15th. We are closing this issue now. Please create an issue on GitHub if you still feel passionate about getting it resolved.

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