Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Gradle Web Engineering Build


May 25, 2021 Gradle


Table of contents


Web engineering build

This chapter describes Gradle's support for Web engineering. G radle provides two main plug-ins for web development, War plugin and Jetty plugin. W here War plugin is inherited from Java plugin, it can be used to play war packages. Jetty plugin is inherited from War plugin as a container for engineering deployments.

Hit the War pack

You need to package the War file, you need to use War plugin in your script:

War plugin

build.gradle

apply plugin: 'war'

Note: This sample code can be found under the samples/webApplication/quickstart path in the Gradle distribution package.

Because it inherits from the Java plug-in, when you perform the gradle build, your project is compiled, tested, and packaged. G radle looks src/main/webapp The compiled classes file and runtime dependencies are also included in the War package.

Groovy web build

You can use multiple plug-ins in a single project. F or example, you can use both War plugin and Groovy plugin in web engineering. The plug-in adds the Gradle dependency to your War package.

The Web project starts

To start a web project, simply use Jetty plugin:

Start a web project with Jetty plugin

build.gradle

apply plugin: 'jetty'

Since Jetty plugin inherits from War plugin. C alling gradle jettyRun will deploy your project startup to the jetty container. Calling gradle jettyRunWar packages and starts deployment to the jetty container.

To be added: Which URL to use, configure the port, where to use the source file, edit your file, and reload the content.