您的位置:首页 > 理论基础 > 计算机网络

【转载】Gradle学习 第十章:网络应用快速入门

2016-04-24 18:51 567 查看
转载地址:http://ask.android-studio.org/?/article/8

This chapter is a work in progress.这一章是一项正在进行中的工作。

This chapter introduces the Gradle support for web applications. Gradle provides two plugins for web application development: the War plugin and the Jetty plugin. The War plugin extends the Java plugin to build a WAR file for your project. The Jetty plugin extends the War plugin to allow you to deploy your web application to an embedded Jetty web container.
<翻译>这一章介绍Gradle对网络应用的支持。Gradle为网络应用开发提供了2个插件:War和Jetty。War继承自Java,为你的项目构建一个War文件。Jetty继承自War,允许你部署你的网络应用到一个嵌入式Jetty网络容器。

10.1. Building a WAR file 构建一个War文件

To build a WAR file, you apply the War plugin to your project:
<翻译>如果想要构建一个War文件,你需要在你的项目中应用War插件

Example 10.1. War plugin
<翻译>例 10.1.War插件

build.gradle
apply plugin: 'war'


Note: The code for this example can be found at samples/webApplication/quickstart which is in both the binary and source distributions of Gradle.
This also applies the Java plugin to your project. Running gradle build will compile, test and WAR your project. Gradle will look for the source files to include in the WAR file in src/main/webapp. Your compiled classes and their runtime dependencies are also included in the WAR file, in the WEB-INF/classes and WEB-INF/lib directories, respectively.
<翻译>笔记:例子的代码可以在Gradle的二进制和源分布文件的samples/webApplication/quickstart中找到。同时也需要在你的项目中应用Java插件。运行gradle build命令将编译,测试和打包(War包)你的项目。gradle将查找源文件放到war文件的src/main/webapp路径下。你编译的类和它们运行时的依赖文件也会分别放到war文件的WEB-INF/classes和WEB-INF/lib路径下。

Groovy web applications Groovy网络应用

You can combine multiple plugins in a single project, so you can use the War and Groovy plugins together to build a Groovy based web application. The appropriate Groovy libraries will be added to the WAR file for you.
<翻译>你能够在一个项目中结合多个插件,所以你可以同时使用War和Groovy构建一个基于Groovy的网络应用

10.2. Running your web application 运行你的网络应用

To run your web application, you apply the Jetty plugin to your project:
<翻译>如果想要运行你的网络应用,你需要在你的项目中应用Jetty插件。

Example 10.2. Running web application with Jetty plugin
<翻译>例 10.2.使用Jetty插件运行网络应用

build.gradle
apply plugin: 'jetty'


This also applies the War plugin to your project. Running gradle jettyRun will run your web application in an embedded Jetty web container. Running gradle jettyRunWar will build the WAR file, and then run it in an embedded web container.
<翻译>这里同样需要在你的项目中应用War插件。运行gradle jettyRun命令将在一个嵌入式Jetty玩了容器中运行你的网络应用。运行gradle jettyRunWar命令将构建War文件,接着在一个嵌入式Jetty玩了容器中运行你的网络应用。

TODO: which url, configure port, uses source files in place and can edit your files and reload.
<翻译> TODO:哪个url,配置端口,使用源文件并编辑和重载你的文件。

10.3. Summary 摘要

You can find out more about the War plugin in Chapter 26, The War Plugin and the Jetty plugin in Chapter 28, The Jetty Plugin. You can find more sample Java projects in the samples/webApplication directory in the Gradle distribution.
<翻译>你可以在第二十六章中发现更多关于War插件的说明,在第二十六章中发现更多关于War插件和Jetty插件的说明。你可以在gradle中samples/webApplication找到更多的java项目示例。

原文地址:http://www.gradle.org/docs/cur ... .html
翻译者:wellchang
邮箱:2483808264@qq.com

如对翻译内容有异议,请在评论区提出或联系作者
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: