Gradle tutorial description Chapter 1 Web applications-Quick Start and gradle Quick Start

Source: Internet
Author: User

Gradle tutorial description Chapter 1 Web applications-Quick Start and gradle Quick Start

This chapter is an ongoing work


This chapter describes Gradle support for Web applications. Gradle provides two plug-ins for Web applications: War plug-ins and Jetty plug-ins.

The War plugin extends the Java Plugin to build your project WAR file.

The Jetty plugin extends the War plugin so that you can deploy your Web application to an embedded Jetty Web container.

Sample programs in this chapter: samples/webApplication/quickstart


10.1 to build a WAR file, you must apply the WAR plug-in.

Example: war plug-in
Build. gradle:

Apply plugin: 'War'

This also applies Java Plug-ins to your project. Run> gradle build to compile, test, and compress the project (the WAR package is under the build/lib directory ).
Gradle will include the source code file under src/main/webapp in the WAR file:

Under the WEB-INF/classes and WEB-INF/lib directories, compiled classes and their runtime dependencies are also included in the WAR file.


10.2 To run a Web application, run the Web application and apply the Jetty plug-in to your project:

For example, run the Web application using the Jetty plug-in.
Build. gradle:
Apply plugin: 'jetty'

This also applies the War plug-in to your project. Run> gradle jettyRun Web application will run in the embedded Web Container Jetty.

Run> gradle jettyRunWar to build the WAR file and then run it in Jetty.

Complete 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
Stopports = 9451
StopKey = 'foo'


Groovy-based Web applications you can use multiple plug-ins in a single project, so you can use the War and Groovy plug-ins to create a Groovy-based Web application. The appropriate Gradle library will be added to your WAR file.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.