-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support array syntax for lists of things
- Loading branch information
Showing
6 changed files
with
67 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
buildSrc/src/main/groovy/com/widen/plugins/buildkite/PluginBuilder.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.widen.plugins.buildkite | ||
|
||
class PluginBuilder { | ||
protected final Map<String, Object> model = [:] | ||
|
||
static Object expand(Object value) { | ||
if (value instanceof Closure) { | ||
def builder = new PluginBuilder() | ||
Closure cloned = (Closure) value.clone() | ||
cloned.delegate = builder | ||
cloned.resolveStrategy = Closure.DELEGATE_FIRST | ||
cloned.call() | ||
value = builder.model | ||
} | ||
|
||
if (value instanceof Map) { | ||
return value.collectEntries { | ||
[(it.key): expand(it.value)] | ||
} | ||
} | ||
|
||
if (value instanceof Iterable) { | ||
return value.collect { | ||
expand(it) | ||
} | ||
} | ||
|
||
return value | ||
} | ||
|
||
Object invokeMethod(String name, Object args) { | ||
Collection expandedArgs = args.collect { | ||
expand(it) | ||
} | ||
|
||
if (expandedArgs.isEmpty()) { | ||
model[name] = null | ||
} else if (expandedArgs.size() == 1) { | ||
model[name] = expandedArgs[0] | ||
} else { | ||
model[name] = expandedArgs | ||
} | ||
} | ||
|
||
void setProperty(String propertyName, Object newValue) { | ||
model[propertyName] = expand(newValue) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
def ctx = context(pathRegexp: /.*\/pipeline(\.[^.]+)?\.gradle/) | ||
|
||
contributor(ctx) { | ||
delegatesTo(findClass('com.widen.plugins.buildkite.BuildkitePipeline')) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
#Wed Oct 21 16:26:08 CDT 2020 | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME |