This chapter is a work in progress
This chapter describes gradle support for Web applications. Gradle provides two plugins for Web Applications : The war plug-in and the jetty plugin.
The war plugin expands the Java plugin to build your project war file.
The jetty plugin expands the war plug-in so you can deploy your Web application to an embedded jetty Web container.
example programs in this chapter: Samples/webapplication/quickstart
10.1 Building a war fileto build a war file, you need to apply the war plugin.
example, war plugin
Build.gradle:
Apply plugin: ' War '
This will also apply the Java plugin to your project. Run > gradle build will compile the project, test and fight the war package (the war package is in the Build/lib directory).
Gradle will include the source files under Src/main/webapp in the war file:
Web-inf/classes and Web-inf/lib directories, the compiled classes and their run-time dependencies are also included in the war file.
10.2 Running the Web applicationto run the Web application, apply the jetty plugin to your project:
example, usingJetty Plug-inrun the Web application
Build.gradle:
Apply plugin: ' Jetty '
This will also apply the war plugin to your project. Run >Gradle JettyrunWeb Applicationwill run in the embedded web containerin Jetty.
Run > gradle jettyrunwar will build the war file and run it in jetty.
Full Build.gradle:
Apply plugin: ' War '
Apply plugin: ' Jetty '
repositories {
Mavencentral ()
}
dependencies {
Compile group: ' Commons-io ', Name: ' Commons-io ', version: ' 1.4 '
Compile group: ' log4j ', Name: ' log4j ', version: ' 1.2.15 ', ext: ' jar '
}
Httpport = 8080
Stopport = 9451
Stopkey = ' foo '
Groovy-based Web applications You can use multiple plugins in a single project, so you can work with war and Gro?? Ovy plug-ins to build a groovy-based Web application together. The appropriate Gradle library will be added to your war file.
Gradle Tutorial Description User Guide 10th Web application----Quick Start