Gradle Tutorial Description User Guide Chapter 10th Web application----Quick Start

Source: Internet
Author: User

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 program for 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 application to run the Web application, apply the jetty plugin to your project:

Span style= "line-height:26px" >jetty plugin   Run Web application
build.gradle:
apply plugin: ' Jetty '

This will also apply the war plugin to your project. Run >  gradle jettyrun  web application will run in an embedded web container jetty in

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 applicationsYou 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 Chapter 10th Web application----Quick Start

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.