Book Image

Gradle Effective Implementations Guide - Second Edition

By : Hubert Klein Ikkink
Book Image

Gradle Effective Implementations Guide - Second Edition

By: Hubert Klein Ikkink

Overview of this book

Gradle is a project automation tool that has a wide range of applications. The basic aim of Gradle is to automate a wide variety of tasks performed by software developers, including compiling computer source code to binary code, packaging binary codes, running tests, deploying applications to production systems, and creating documentation. The book will start with the fundamentals of Gradle and introduce you to the tools that will be used in further chapters. You will learn to create and work with Gradle scripts and then see how to use Gradle to build your Java Projects. While building Java application, you will find out about other important topics such as dependency management, publishing artifacts, and integrating the application with other JVM languages such as Scala and Groovy. By the end of this book, you will be able to use Gradle in your daily development. Writing tasks, applying plugins, and creating build logic will be your second nature.
Table of Contents (18 chapters)
Gradle Effective Implementations Guide - Second Edition
About the Author
About the Reviewer

Using the Jetty plugin

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. You can learn more about Jetty at 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 build.gradle file in the web directory. Here, we will use the apply() method to add the Jetty plugin to the project:

apply plugin: 'jetty' 

The plugin adds the following tasks to our project: jettyRunjettyRunWar, and jettyStop. The following table shows the different...