First, thanks to Peter for the catch on the single quote. That got left in 
there from my many iterations of attempts at success.

Eventually I also had to add the dir attribute to resolve a classpath issue. 
Clearly, using Maven the last couple of years has made me rusty at my Ant.

Etienne, thanks for bringing the lifecycle to my attention. I will read up on 
that now.

One last thing: I have found that the failonerror attribute on the java task 
isn't working for me. Is anyone seeing that? If so, does anyone care and 
consider that a bug?

Thanks.



On Feb 26, 2011, at 7:49 AM, Etienne Studer wrote:

Minor correction to my previous code sample where I forgot the task name:

task startTomcat << {
  ant.java(...)
}

Etienne



On 26.02.2011, at 09:08, Etienne Studer wrote:

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'<smb://bin//bootstrap.jar'>", fork: "true") {
    arg value: "start"
    classpath {
      pathelement path: tomcatHome + "\\lib<smb://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]<mailto:[email protected]>

www.canoo.com<http://www.canoo.com/>




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]<mailto:[email protected]>

www.canoo.com<http://www.canoo.com/>




Reply via email to