Skip to content

Instantly share code, notes, and snippets.

@scheakur
Created January 24, 2013 16:00
Show Gist options
  • Save scheakur/4623800 to your computer and use it in GitHub Desktop.
Save scheakur/4623800 to your computer and use it in GitHub Desktop.
project.ext.files = []
tasks.addRule('Use files as arguments') { taskName ->
if (!taskName.equals('dosomething') && file(taskName).isFile()) {
files.add taskName
task(taskName) // Define task to prevent task-not-found error
}
}
task dosomething << {
println 'do something'
println files
}
$ gradle dosomething files/a.txt files/b.txt
:dosomething
do something
[files/a.txt, files/b.txt]
:files/a.txt UP-TO-DATE
:files/b.txt UP-TO-DATE
$ gradle dosomething files/a.txt files/b.txt -q
do something
[files/a.txt, files/b.txt]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment