On 08/01/2011, at 7:28 PM, Hendy Irawan wrote:

> 
> I'm trying to run a custom task from inside a regular task.
> 
> My custom task is:
> 
> class SshTask extends DefaultTask {
>       String user
>       String host
>       String command
> 
>       @TaskAction
>       void run() {
>               project.exec {
>                       commandLine 'ssh', "$u...@$host", command
>               }
>       }
> }
> 
> My regular task is :
> 
> task deploy {
>       description = 'Deploy the download to remote server. Specify $user, 
> $host,
> and $deploymentDir.'
>       doLast {
>               ssh = new SshTask()
>               ssh.configure {
>                       user = server.user
>                       host = server.host
>                       command = "mkdir -vp $server.dir"
>               }
>               ssh.execute()
>       }
> }
> 

It's not really a task if you plan to use it this way - it's just a regular 
class. You can get rid of the 'extends DefaultTask' from SshTask.


--
Adam Murdoch
Gradle Developer
http://www.gradle.org
CTO, Gradle Inc. - Gradle Training, Support, Consulting
http://www.gradle.biz

Reply via email to