-
Book Overview & Buying
-
Table Of Contents
Gradle Effective Implementation Guide
By :
In the previous section, we created a Java project with a web subproject. The web project has a simple servlet. To execute the servlet, we must create a WAR file and deploy the WAR file to a servlet container such as Tomcat or Jetty.
With the Jetty plugin, we can run our web project from the command line in a Jetty web container. We don't have to install Jetty on our computer; we only need to apply the Jetty plugin to our project. The plugin will take care of configuring Jetty and starting the web container. If everything is okay, we can open a web browser and access our servlet.
To add the Jetty plugin to our web project, let's create a new file, build.gradle, in the web directory. Here, we use the apply() method to add the Jetty plugin to the project:
apply plugin: 'jetty'
The plugin adds the following tasks to our project: jettyRun, jettyRunWar, and jettyStop. The following table shows the different tasks:
|
Task |
Depends on |
Type |
Description |
|---|---|---|---|
|
|
|
Change the font size
Change margin width
Change background colour