First use IntelliJ to create a new Gradle Project. Second create a standard project structure for a webapp like:
src/main/java/yourPackage/yourServlet.java
src/main/webapp/WEB-INF/web.xml
src/main/webapp/index.html
Add the following to your gradle.build file:
apply plugin: 'jetty'
//also applies plugin: 'war'
//and this also applies plugin: 'java'
repositories{
mavenCentral()
}
dependencies {
compile 'javax.servlet:javax.servlet-api:3.1.0'
}
Now you can just build your project with the gradle (or gradlew if you use the wrapper) build task and run it with the jettyRun task. If you don't want to use jetty, you can use the war plugin without the jetty plugin and deploy your generated war file on every server you want. The war file will be located in projectRoot/build/libs
See also the user guide of gradle: Chapter 47. Web Application Quickstart