Hi,
I have a task like this:
task deploy (dependsOn: war) << {
if(project.hasProperty('installDir')){
print 'Deploying war file ' + war.archiveName + ' ... '
File instDir = new File(installDir + '/server/default/deploy')
if(instDir.exists() && instDir.isDirectory()){
int waiting = 30
print 'waiting ' + waiting + ' seconds ... '
copy {
from war.archivePath
into instDir
}
Thread.sleep(waiting * 1000)
println 'done.'
} else {
println 'Skipping as folder ' + instDir.getPath() + ' does not exist.'
}
} else {
throw new TaskInstantiationException('No installDir given for Deployment.\n' +
'* Specify it with \'-PinstallDir=\'')
}
}
I use this one in two places right now with more to come. There is a lot of repetitive code and basically only one thing that changes (the from part).
How can I predefine a kind of template that I could use everywhere only providing the from part?
Thanks,
Sven