diff --git a/build/gradle.go b/build/gradle.go index cd261fd1..6099c9cd 100644 --- a/build/gradle.go +++ b/build/gradle.go @@ -265,16 +265,20 @@ func (config *gradleRunConfig) GetCmd() *exec.Cmd { func handleGradleCommandProperties(tasks []string) []string { var cmdArgs []string for _, task := range tasks { - if !strings.HasPrefix(task, systemPropertiesFlag) && !strings.HasPrefix(task, projectPropertiesFlag) { - cmdArgs = append(cmdArgs, task) - continue + if isGradleSystemOrProjectProperty(task) { + propertyParts := strings.SplitN(task, "=", 2) + task = fmt.Sprintf(`%s="%s"`, propertyParts[0], propertyParts[1]) } - propertyParts := strings.SplitN(task, "=", 2) - cmdArgs = append(cmdArgs, fmt.Sprintf(`%s="%s"`, propertyParts[0], propertyParts[1])) + cmdArgs = append(cmdArgs, task) } return cmdArgs } +func isGradleSystemOrProjectProperty(task string) bool { + hasPropertiesFlag := strings.HasPrefix(task, systemPropertiesFlag) || strings.HasPrefix(task, projectPropertiesFlag) + return hasPropertiesFlag && strings.Contains(task, "=") +} + func (config *gradleRunConfig) runCmd(stdout, stderr io.Writer) error { command := config.GetCmd() command.Env = os.Environ() diff --git a/build/gradle_test.go b/build/gradle_test.go index 77e01ff1..e813a67d 100644 --- a/build/gradle_test.go +++ b/build/gradle_test.go @@ -124,6 +124,10 @@ func TestHandleGradleCommandProperties(t *testing.T) { input: []string{"-Dparam1=value1", "run", "-Pkey2=value2", "-Dparam2=value2"}, expected: []string{`-Dparam1="value1"`, "run", `-Pkey2="value2"`, `-Dparam2="value2"`}, }, + { + input: []string{"-Dparam1=value1", "run", "-Psign"}, + expected: []string{`-Dparam1="value1"`, "run", "-Psign"}, + }, } for _, test := range tests {