On 19/04/2011, at 7:30 AM, StormeHawke wrote:
>
> Szczepan Faber wrote:
>>
>> Oups, a correction to (2):
>>
>> task stopTomcat(type:Exec) {
>> commandLine = ['cmd', '/c', 'stop.bat']
>> workingDir = file('../tomcat/bin')
>> }
>>
> Ok, this works, though it breaks completely if I try to run it when Tomcat
> is already stopped, and I had to change it to the following:
> commandLine = ['cmd', '/c', 'net', 'stop', 'Apache Tomcat']
>
> But ultimately what I would like to be able to do is write a single task
> that does everything I mentioned above. I've found this:
>
> http://www.gradle.org/1.0-milestone-2/docs/userguide/custom_tasks.html
>
> and I'm working on creating a custom Task that solves this for me. However,
> I'm not seeing anything in that document on how to make my new custom
> DeployTomcatTask dependent on the "war" task's output file?
A typical approach is to use a custom plugin, which creates the deploy task and
configures it appropriately. Your plugin would do something like:
deploy.dependsOn war
You could potentially put this code in the task itself, but this does couple
the task implementation a bit too tightly to your particular project and limits
your options for reusing the task. This may or may not be an issue for you.
--
Adam Murdoch
Gradle Co-founder
http://www.gradle.org
VP of Engineering, Gradleware Inc. - Gradle Training, Support, Consulting
http://www.gradleware.com