Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run a gradle web application?

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?

like image 203
Ruby Avatar asked Feb 27 '13 11:02

Ruby


People also ask

How do I run a Gradle application?

If you press the run button in Android Studio, it triggers the corresponding Gradle task and starts the application. You can also run Gradle via the command line. To avoid unnecessary local installation, Gradle provides a wrapper script which allows you to run Gradle without any local installation.

How do I run simple Gradle project?

From inside the new project directory, run the init task using the following command in a terminal: gradle init . When prompted, select the 2: application project type and 3: Java as implementation language. Next you can choose the DSL for writing buildscripts - 1 : Groovy or 2: Kotlin .


1 Answers

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.

like image 71
Cengiz Avatar answered Nov 11 '22 11:11

Cengiz