Skip to content

Commit

Permalink
Merge pull request #16 from devindi/update_dsl
Browse files Browse the repository at this point in the history
  • Loading branch information
devindi authored Oct 24, 2019
2 parents f390a50 + 56414fe commit 748f49f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 96 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,4 @@ class DiawiUploadExtension {
String comment
OutputExtension output = new OutputExtension()
CallbackExtension callback = new CallbackExtension()

// those props will be removed at version 2.0
@Deprecated
OutputStream standardOutput
@Deprecated
String callbackEmail
@Deprecated
String callbackUrl
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class DiawiUploadTask extends DefaultTask {
println "Build uploaded OK. Hash = $hash"

String outputFormat = uploadExtension.output.format
OutputStream outputStream = findOutputStream()
OutputStream outputStream = uploadExtension.output.stream

List<ReplacementItem> replacements = [
new ReplacementItem("date", new Date().toString()),
Expand All @@ -58,26 +58,4 @@ class DiawiUploadTask extends DefaultTask {
outputStream.write(formattedOutput.bytes)
outputStream.flush()
}

private OutputStream findOutputStream() {
def value = uploadExtension.output.stream
def backport = uploadExtension.standardOutput

if (value != null && backport == null) {
// new dsl used, ok
return value
}

if (value == null && backport != null) {
logger.warn("Property 'diawi.standartOutput' is deprecated and will be removed in future. Use diawi.output.stream instead")
return backport
}

if (value != backport) {
logger.warn("Property 'diawi.standartOutput' is deprecated and will be removed in future. Use diawi.output.stream instead. Value of 'diawi.standartOutput' ignored")
return value
}

throw new IllegalStateException("Failed to resolve output stream")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,10 @@ package com.devindi.gradle.diawi.task.internal

import com.devindi.gradle.diawi.diawi.UploadParams
import com.devindi.gradle.diawi.dsl.DiawiUploadExtension
import com.google.common.base.Strings
import org.gradle.api.logging.Logger

class UploadParamsFactory {

final Logger logger

UploadParamsFactory(Logger logger) {
this.logger = logger
}

UploadParams createParams(DiawiUploadExtension extension) {
static UploadParams createParams(DiawiUploadExtension extension) {
def token = extension.token
def wallOfApps = extension.wallOfApps
def password = extension.password
Expand All @@ -24,62 +16,8 @@ class UploadParamsFactory {
wallOfApps,
password,
comment,
findCallbackUrl(extension),
findCallbackEmails(extension)
extension.callback.url,
extension.callback.emails.join(",")
)
}

private String findCallbackUrl(DiawiUploadExtension extension) {
def value = extension.callback.url
def backport = extension.callbackUrl

if (Strings.isNullOrEmpty(value) && Strings.isNullOrEmpty(backport)) {
return null
}

if (!Strings.isNullOrEmpty(value) && Strings.isNullOrEmpty(backport)) {
// new dsl used, ok
return value
}

if (Strings.isNullOrEmpty(value) && !Strings.isNullOrEmpty(backport)) {
logger.warn("Property 'diawi.callbackUrl' is deprecated and will be removed in future. Use diawi.callback.url instead")
return backport
}

if (value != backport) {
logger.warn("Property 'diawi.callbackUrl' is deprecated and will be removed in future. Use diawi.callback.url instead. Value of 'diawi.callbackUrl' ignored")
return value
}

logger.error("Failed to resolve callback url")
return null
}

private String findCallbackEmails(DiawiUploadExtension extension) {
def value = extension.callback.emails.join(",")
def backport = extension.callbackEmail

if (Strings.isNullOrEmpty(value) && Strings.isNullOrEmpty(backport)) {
return null
}

if (!Strings.isNullOrEmpty(value) && Strings.isNullOrEmpty(backport)) {
// new dsl used, ok
return value
}

if (Strings.isNullOrEmpty(value) && !Strings.isNullOrEmpty(backport)) {
logger.warn("Property 'diawi.callbackEmail' is deprecated and will be removed in future. Use diawi.callback.emails instead")
return backport
}

if (value != backport) {
logger.warn("Property 'diawi.callbackEmail' is deprecated and will be removed in future. Use diawi.callback.emails instead. Value of 'diawi.callbackEmail' ignored")
return value
}

logger.error("Failed to resolve callback emails")
return null
}
}

0 comments on commit 748f49f

Please sign in to comment.