How to run a gradle web application?

Ruby picture Ruby · Feb 27, 2013 · Viewed 10.5k times · Source

I have converted a maven project to gradle , I am using Spring tool suite and all the dependency jars are uploaded successfully .When I build the project it builds successfully. but I am not getting an idea how to run this web application , I tried to make a war so that I can used tomcat to deploy , I found tomcat plugin for that but when I insert tomcat plugin in my build.gradle file ,it gives me error: Plugin with tomcat id not found

Please help someone I am just stuck , I am assuming the structure it follows is same as gradle and as I am using jsp pages and xml files can I keep these files in my resources folder .

How can i create the war file of project and deploy using eclipse-wtp in tomcat?

Answer

Cengiz picture Cengiz · Feb 27, 2013

To create a war just use: apply plugin: 'war'

For WTP add these lines to your build.gradle:

apply plugin: 'eclipse'
apply plugin: 'eclipse-wtp'

To deploy the war file with tomcat within your build you can use the cargo plugin. In that way you can start after the deployment e.g. integration tests etc.

To deploy the war file within eclipse tomcat: You must first run gradle eclipse after you put the above apply plugin: ... into your build.gradle. Then refresh within eclipse and add the web project to your tomcat.