Gradle 1.9 command line args getting passed to exec on Windows

(Eric Woodruff) #1

I’m having a strange unexpected issue that is difficult to research for because of the command line context. Basically I’m testing a gradle script on Windows that has been working on Linux. The output suggests, and I have verified, that the args to gradle are getting passed to this exec call within the script, and they should not be.

Here’s the output:

Starting process ‘command ‘F:\jenkins\workspace\OEM_Gradle_Test\build/emsdk/bin/empdk.bat’’. Working directory:

F:\jenkins\workspace\OEM_Gradle_Test Command: F:\jenkins\workspace\OEM_Gradle_Test\build/emsdk/bin/empdk.bat create_plugin -stage_dir F:\jenkins\workspace\OEM_Gradle_Test\build\opar -out_dir F:\jenkins\workspace\OEM_Gradle_Test\build -tmp_dir F:\jenkins\workspace\OEM_Gradle_Test\build\tmp\createPlugin

Successfully started process ‘command ‘F:\jenkins\workspace\OEM_Gradle_Test\build/emsdk/bin/empdk.bat’’

Error :unknown parameter: --info

There’s no --info parameter passed in this gradle script:

exec {
                                                                                                                                                                 commandLine "${emSdk.dir}/bin/${empdkBin}", 'create_plugin', '-stage_dir', fixPath("${stageDir2}"), '-out_dir', fixPath("${buildDir}"), '-tmp_dir', fixPath("${temporaryDir}")

The --info parameter actually comes from the gradle commandline itself. I verified this by removing --info from the gradle command and then the build fails with “Error :unknown parameter: build” which is the name of the build target.

For context, this build is started by the Jenkins Gradle plugin.

(Benjamin Muschko) #2

What exactly does the method fixPath do? Looking at the output it seems as if a path contains slashes as well as backslashes. Is there a reason for it?

(Eric Woodruff) #3

Just as a precaution for external tools. The forward slashes that are there are in the command itself, which I presume is handled by a Java ProcessBuilder used by Gradle.

def fixPath§ {

if (Os.isFamily(Os.FAMILY_WINDOWS)) {

return p.replace(’/’, ‘\\’)

} else {

return p

} }

(Benjamin Muschko) #4

Should it say p.replace(’//’, ‘\’) ?

(Benjamin Muschko) #5

Could you also try to run the task with -s to see if there’s more information provided by the stack trace?

(Eric Woodruff) #6

I don’t think there is a useful stacktrace since the error is in a child process. Let me try to change the command to echo instead.

(Eric Woodruff) #7

It turns out to be inheriting the environment variable CMD_LINE_ARGS from somewhere in the process hierarchy (I think gradlew.bat). Clearing it with environment CMD_LINE_ARGS: “” fixed the issue.