Hi Neil
Are you aware that you are starting Tomcat during the configuration phase of
Gradle and not during the execution phase?
If you add the <<, Tomcat will be started during the execution phase of Gradle.
This would also make sure that Tomcat is only started if Gradle determines that
the startTomcat task needs to run, i.e. startTomcat is specified on the command
line or it is a dependency of a task specified on the command line.
task << {
ant.java(...)
}
Regards, Etienne
On 26.02.2011, at 01:59, Neil Chaudhuri wrote:
> I would like to start and stop Tomcat with Gradle tasks, but I figured I
> would start slowly and see if I could get things started first. Here is my
> task (executed on my Windows box):
>
> tomcatHome = System.getenv()["CATALINA_HOME"]
>
> task startTomcat() {
> ant.java(jar: tomcatHome + "\\bin\\bootstrap.jar'", fork: "true") {
> arg value: "start"
> classpath {
> pathelement path: tomcatHome + "\\lib"
> }
> }
> }
>
> The result is this:
>
> 19:51:38.234 [DEBUG] [org.gradle.api.internal.project.ant.AntLoggingAdapter]
> Execute:Java13CommandLauncher: Executing 'C:\Sun\SDK\jdk\jre\bin\java.exe'
> with arguments:
> '-classpath'
> 'C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib'
> '-jar'
> 'C:\Program Files\Apache Software Foundation\Tomcat 6.0\bin\bootstrap.jar''
> 'start'
>
> The ' characters around the executable and arguments are
> not part of the command.
> 19:51:38.343 [INFO] [org.gradle.api.internal.project.ant.AntLoggingAdapter]
> [ant:java] Unable to access jarfile C:\Program Files\Apache Software
> Foundation\Tomcat 6.0\bin\bootstrap.jar'
>
> Assume that file is there. Is there anything obviously wrong I am doing?
>
> Incidentally, I tried adding escaped quotation marks to account for the
> spaces in the path, but that really made things weird.
>
> Any insight would be appreciated.
>
> Thanks.
Etienne Studer
Senior Software Developer
Canoo Engineering AG
Kirschgartenstrasse 5
CH-4051 Basel
T +41 61 228 94 44
F +41 61 228 94 49
[email protected]
www.canoo.com