Skip to content

Instantly share code, notes, and snippets.

@hansd
Created November 30, 2011 14:48
Show Gist options
  • Save hansd/1409317 to your computer and use it in GitHub Desktop.
Save hansd/1409317 to your computer and use it in GitHub Desktop.
Autowiring with tasks
task analyzeTestJar(type: AnalyzeJar) {
jar = testJar
}
task copy(type:Copy) {
from testJar
into 'build/myJars'
}
class AnalyzeJar extends DefaultTask {
Task jar
AnalyzeJar() {
inputs.files { jar.outputs.files }
}
@TaskAction
def analyze() {
println "Size: ${jar.archivePath.size()}"
project.exec {
commandLine "unzip", "-t", jar.archivePath
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment