Created
April 1, 2011 20:49
-
-
Save musketyr/898832 to your computer and use it in GitHub Desktop.
How could be simply passed arguments to the Gradle build
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
task args | |
args.map = [:] | |
tasks.addRule("Pattern: <property>=<value>: Passes arguments to the scripts") { String taskName -> | |
def match = taskName =~ /(.*?)=(.*?$)/ | |
if(match){ | |
args.map[match[0][1]] = match[0][2] | |
task(taskName) << { | |
println "Used to pass value ${match[0][2]} to args.map.${match[0][1]}" | |
} | |
} | |
} | |
task testaArgs(dependsOn: args) << { | |
if(args.map){ | |
println "Arguments passed:" | |
args.map.each{ property, value -> | |
println "\t $property=$value" | |
} | |
} else { | |
println "No arguments passed!" | |
} | |
if(args.map.plugin){ | |
println "Plugin: $args.map.plugin" | |
} else { | |
println 'No plugin selected' | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment