Skip to content

Commit

Permalink
Filtering out empty curlArgs
Browse files Browse the repository at this point in the history
  • Loading branch information
yannickpulver committed Jul 9, 2024
1 parent e7916d1 commit ff0f2e9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 14 additions & 16 deletions lib/src/main/groovy/com/appswithlove/updraft/UpdraftPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ class UpdraftPlugin implements Plugin<Project> {
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()]
Expand All @@ -105,25 +103,25 @@ class UpdraftPlugin implements Plugin<Project> {

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<String> 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) {
Expand Down Expand Up @@ -198,7 +196,7 @@ class UpdraftPlugin implements Plugin<Project> {
if (text.isBlank() || text.isEmpty()) {
""
} else {
"-F \"${name}=${text}\" "
"-F ${name}=${text} "
}
}
}

0 comments on commit ff0f2e9

Please sign in to comment.