From ff0f2e9bf07ede6677430c1a6a3dc21c05858302 Mon Sep 17 00:00:00 2001 From: Yannick Date: Tue, 9 Jul 2024 08:33:52 +0200 Subject: [PATCH] Filtering out empty curlArgs --- gradle.properties | 2 +- .../appswithlove/updraft/UpdraftPlugin.groovy | 30 +++++++++---------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/gradle.properties b/gradle.properties index b80e90d..c415d26 100644 --- a/gradle.properties +++ b/gradle.properties @@ -19,7 +19,7 @@ GROUP=com.appswithlove.updraft POM_ARTIFACT_ID=updraft -VERSION_NAME=2.2.5 +VERSION_NAME=2.2.6 POM_NAME=updraft-plugin-android POM_DESCRIPTION=This is a gradle Android plugin for automated uploads to Updraft diff --git a/lib/src/main/groovy/com/appswithlove/updraft/UpdraftPlugin.groovy b/lib/src/main/groovy/com/appswithlove/updraft/UpdraftPlugin.groovy index 4b7fdb2..ffd0340 100644 --- a/lib/src/main/groovy/com/appswithlove/updraft/UpdraftPlugin.groovy +++ b/lib/src/main/groovy/com/appswithlove/updraft/UpdraftPlugin.groovy @@ -85,8 +85,6 @@ class UpdraftPlugin implements Plugin { def gitUrl = createCurlParam(executeGitCommand("git config --get remote.origin.url"), "custom_URL") def releaseNotes = getReleaseNotes(project, variant) - println("releaseNotes: $releaseNotes") - def whatsNew = createCurlParam(releaseNotes, "whats_new") def urls = project.updraft.urls[variant.name.capitalize()] @@ -105,25 +103,25 @@ class UpdraftPlugin implements Plugin { for (String url in urls) { //Build and execute of the curl command for Updraft upload - - println("Curl command --> curl -X PUT -F app=@${file} -F build_type=Gradle ${gitBranch} ${gitUrl} ${gitTags} ${gitCommit} ${whatsNew} ${url}") + List curlArgs = [ + '-X', 'PUT', + '-F', "app=@${file}", + '-F', "build_type=Gradle", + gitBranch, + gitUrl, + gitTags, + gitCommit, + whatsNew, + url + ].findAll { it != '' } // Filter out empty strings new ByteArrayOutputStream().withStream { os -> - def result = project.exec { + project.exec { executable 'curl' - args '-X', 'PUT', - '-F', "\"app=@${file}\"", - '-F', "\"build_type=Gradle\"", - gitBranch, - gitUrl, - gitTags, - gitCommit, - whatsNew, - url + args curlArgs standardOutput os } - def execResponse = new JsonSlurperClassic().parseText(os.toString()) if (execResponse instanceof HashMap && execResponse.size() > 0) { @@ -198,7 +196,7 @@ class UpdraftPlugin implements Plugin { if (text.isBlank() || text.isEmpty()) { "" } else { - "-F \"${name}=${text}\" " + "-F ${name}=${text} " } } }