Gradle2.0用户指南翻译——第十章. Web 应用程序快速入门

翻译项目请关注Github上的地址:
https://github.com/msdx/gradledoc
本文翻译所在分支:
https://github.com/msdx/gradledoc/tree/2.0 。
在线浏览地址:
http://gradledoc.qiniudn.com/2.0/userguide/userguide.html 。
另外,Android 手机用户可通过我写的一个程序浏览文档,带缓存功能的,目前0.6开发中版本兼容 Android 2.3以上系统,项目地址如下:
https://github.com/msdx/gradle-doc-apk
翻译不易,转载请注明本文在CSDN博客上的出处:
http://blog.csdn.net/maosidiaoxian/article/details/78409069

关于我对Gradle的翻译,以Github上的项目及http://gradledoc.qiniudn.com 上的文档为准。如发现翻译有误的地方,将首先在以上两个地方更新。因时间精力问题,博客中发表的译文基本不会同步修改。


第十章. Web 应用程序快速入门

Chapter 10. Web Application Quickstart

本章还在完善中。
This chapter is a work in progress.

本章介绍了Gradle对Web应用程序的相关支持。Gradle提供了两个用于Web应用开发的插件:War和Jetty。 War插件扩展了Java插件,可以用来构建WAR文件。 Jetty插件扩展了War插件,能将Web应用程序部署到嵌入式Jetty Web容器中。 
This chapter introduces some of the Gradle's 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.

10.1. 构建一个WAR文件

10.1. Building a WAR file

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

示例 10.1. 使用War 插件 - Example 10.1. War plugin

build.gradle

apply plugin: 'war'

注:本示例的代码可以在Gradle的二进制或源代码发行包中的 samples/webApplication/quickstart里找到。
Note: The code for this example can be found at samples/webApplication/quickstart which is in both the binary and source distributions of Gradle.

以上操作也会将Java插件应用到项目中。运行gradle build将对你的项目进行编译,测试和并打成WAR包。 Gradle将查找在src/main/webapp目录中的源文件,并与所编译出来的类文件,及其运行时依赖关系一起包含到WAR文件中。 
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.

Groovy web 应用程序

你可以在单个project中组合多个插件,因此你可以将War和Groovy插件一起使用,构建一个基于Groovy的web应用程序。相应的groovy库也会被加入到WAR文件中。
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.

Groovy web applications

10.2. 运行 web 应用程序

10.2. Running your web application

要运行 web 应用程序,需要将 Jetty 插件应用于项目中:
To run your web application, you apply the Jetty plugin to your project:

示例10.2. 使用Jetty插件运行Web应用程序 - Example 10.2. Running web application with Jetty plugin

build.gradle

apply plugin: 'jetty'

以上操作也会将War插件应用到你的项目中。运行gradle jettyRun,将在嵌入式Jetty Web容器中运行你的Web应用程序。运行gradle jettyRunWar将先构建出WAR文件,然后在嵌入式Web容器中运行它。 
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.

TODO:使用哪个url,配置端口,在适当的位置使用源文件,并且可以编辑你的文件和重新加载。
TODO: which url, configure port, uses source files in place and can edit your files and reload.

10.3. 总结

10.3. Summary

你可以在《第二十六章, War插件》在《第二十八章,Jetty 插件》中分别了解更多关于War 及Jetty 插件的内容。并且可以在Gradle的发行包中的samples/webApplication目录中找到更多Java 项目示例。 
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.


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
提供的源码资源涵盖了Java应用等多个领域,每个领域都包含了丰富的实例和项目。这些源码都是基于各自平台的最新技术和标准编写,确保了在对应环境下能够无缝运行。同时,源码中配备了详细的注释和文档,帮助用户快速理解代码结构和实现逻辑。 适用人群: 适合毕业设计、课程设计作业。这些源码资源特别适合大学生群体。无论你是计算机相关专业的学生,还是对其他领域编程感兴趣的学生,这些资源都能为你提供宝贵的学习和实践机会。通过学习和运行这些源码,你可以掌握各平台开发的基础知识,提升编程能力和项目实战经验。 使用场景及目标: 在学习阶段,你可以利用这些源码资源进行课程实践、课外项目或毕业设计。通过分析和运行源码,你将深入了解各平台开发的技术细节和最佳实践,逐步培养起自己的项目开发和问题解决能力。此外,在求职或创业过程中,具备跨平台开发能力的大学生将更具竞争力。 其他说明: 为了确保源码资源的可运行性和易用性,特别注意了以下几点:首先,每份源码都提供了详细的运行环境和依赖说明,确保用户能够轻松搭建起开发环境;其次,源码中的注释和文档都非常完善,方便用户快速上手和理解代码;最后,我会定期更新这些源码资源,以适应各平台技术的最新发展和市场需求。 所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随时与博主沟通,第一时间进行解答!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值