Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PublishDir allows closures for mode, enabled, overwrite fields #2432

Closed
wants to merge 7 commits into from
Closed
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,41 @@ class PublishDir {
this.path = obj.complete()
}

void setMode( Closure obj ) {
setMode( obj.call() as String )
}

void setMode( String str ) {
this.mode = str == 'copyNoFollow' ? Mode.COPY_NO_FOLLOW : str.toUpperCase() as Mode
this.mode = str.toUpperCase() == 'COPYNOFOLLOW' ? Mode.COPY_NO_FOLLOW : str.toUpperCase() as Mode
}

void setMode( Mode mode ) {
this.mode = mode
}

void setOverwrite( Closure obj ) {
setOverwrite( obj.call() as String )
}

void setOverwrite( String str ) {
setOverwrite( Boolean.parseBoolean( str ) )
}

void setOverwrite( Boolean bl ) {
this.overwrite = bl
}

void setEnabled( Closure obj ) {
setEnabled( obj.call() as String )
}

void setEnabled( String str ) {
setEnabled( Boolean.parseBoolean( str ) )
}

void setEnabled( Boolean bl ) {
this.enabled = bl

static @PackageScope Map<String,String> resolveTags( tags ) {
def result = tags instanceof Closure
? tags.call()
Expand Down Expand Up @@ -174,13 +201,13 @@ class PublishDir {
result.pattern = params.pattern

if( params.overwrite != null )
result.overwrite = Boolean.parseBoolean(params.overwrite.toString())
result.overwrite = params.overwrite

if( params.saveAs )
result.saveAs = (Closure) params.saveAs

if( params.enabled != null )
result.enabled = Boolean.parseBoolean(params.enabled.toString())
result.enabled = params.enabled

if( params.failOnError != null )
result.failOnError = Boolean.parseBoolean(params.failOnError.toString())
Expand Down