Java 8 已达到支持终止期限,并将于 2026 年 1 月 31 日
弃用。弃用后,您将无法部署 Java 8 应用,即使您的组织之前曾使用组织政策重新启用旧版运行时的部署,也无法部署。现有的 Java 8 应用在
弃用日期之后将继续运行并接收流量。我们建议您
迁移到最新支持的 Java 版本。
App Engine Gradle 插件任务和属性
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
添加 App Engine 插件到您的项目后,您可以在 App Engine 标准环境中针对应用执行下列 App Engine 特定 Gradle 任务:
任务 |
说明 |
tasks |
显示已安装任务的帮助信息。 |
appengineCloudSdkLogin |
设置账号的全局 gcloud CLI 状态。 |
appengineDeploy |
暂存应用并将其部署到 App Engine。 |
appengineDeployAll |
暂存应用及其所有的有效 yaml 配置,同时将其部署到 App Engine。 |
appengineDeployCron |
暂存 cron.yaml 配置文件并将其部署到 App Engine。 |
appengineDeployDispatch |
暂存 dispatch.yaml 配置文件并将其部署到 App Engine。 |
appengineDeployDos |
暂存 dos.yaml 配置文件并将其部署到 App Engine。 |
appengineDeployIndex |
暂存 index.yaml 配置文件并将其部署到 App Engine。 |
appengineDeployQueue |
暂存 queue.yaml 配置文件并将其部署到 App Engine。 |
appengineRun |
运行 App Engine 开发服务器。服务器运行时,会持续检查以确定 appengine-web.xml 是否已更改。如果已更改,则服务器会重新加载应用。您无需因 appengine-web.xml 的更改而停止和重启应用。 |
appengineStage |
生成用于部署的应用目录。 |
appengineStart |
执行 App Engine 开发服务器的异步启动,然后返回到命令行。当此目标运行时,行为与 run 目标完全相同,但以下情况除外:Gradle 继续处理任务,并在服务器启动并运行后退出。
|
appengineStop |
停止正在运行的 App Engine Web 开发服务器。 |
explodeWar |
将 WAR 文件分离为构建目录。 |
要查看所有任务的列表,请使用以下命令:
gradle tasks
如需详细了解如何设置和使用 Gradle,请参阅使用 App Engine Gradle。
任务属性
gradle.build
文件的内容是描述构建的一组规则。它是基于 Groovy 语言由网域特定的语言编写的,用于描述构建作业。
每个任务都具有可供您使用的如下相关属性。您可以使用配置闭包、任务和属性,在 gradle.build
文件中指定这些属性。
在以下示例中:
- 插件的配置闭包是
appengine
。
- 任务是
run
。
- 属性
port
设置为 8080
。
如果您只需指定少数几项属性,则可以将其排列为一行:
appengine.run.port = 8888
有关每个任务的可用属性列表,请参阅以下部分。
appengineStage
task(stage)
生成用于部署的应用目录。appengineDeploy
任务使用 appengineStage
。
您可以使用以下属性:
属性 | 说明 |
compileEncoding |
编译 JSP 时使用的字符编码。仅适用于在 App Engine 标准环境中运行的应用。
|
deleteJsps |
编译后删除 JSP 源文件。仅适用于在 App Engine 标准环境中运行的应用。
|
disableJarJsps |
禁止添加通过 JSP 生成的类。仅适用于在 App Engine 标准环境中运行的应用。
|
disableUpdateCheck |
不检查 gcloud CLI 更新。 |
enableJarClasses |
将 WEB-INF/classes content 压缩为 jar 文件。仅适用于在 App Engine 标准环境中运行的应用。
|
useMtimeFileWatcher |
使用 mtime 轮询检测源代码更改。如果您使用分布式文件系统通过远程计算机修改代码,则此参数很有用。 |
enableJarSplitting |
将大于 10 MB 的 JAR 文件拆分为多个较小的片段。仅适用于 App Engine 标准环境。
|
enableQuickstart |
使用 Eclipse Jetty 快速启动模块处理 servlet 注释。仅适用于 App Engine 标准环境。
|
jarSplittingExcludes |
从所有 JAR 文件中排除与英文逗号分隔的 SUFFIXES 列表匹配的文件。仅适用于在 App Engine 标准环境中运行的应用。
|
sourceDirectory |
必需。已编译的 Web 应用文件或分离型 WAR 的位置,会用作要暂存的内容的源位置。仅适用于 App Engine 标准环境。默认值为 build/exploded-${gradle-module-name} 。
|
stagingDirectory |
必需。要暂存应用的目录。默认值为 build/staged-app 。
|
appengineRun
task(run)
运行 App Engine 开发 Web 服务器。服务器运行时,会持续检查以确定 appengine-web.xml
是否已更改。如果已更改,则服务器会重新加载应用。也就是说,您无需因 appengine-web.xml
发生更改而停止和重启您的应用。
您可以使用以下属性,其中部分属性对应于本地开发服务器命令行标志:
属性 |
说明 |
environment |
要发送到本地开发服务器的环境变量的映射。
示例:[key1: "value1", key2: "value2"]
|
jvmFlags |
启动应用实例时要传递至 java 命令的其他参数。可以多次指定此参数。示例:
-Xmx1024m -Xms256m
|
host |
应用服务应绑定的主机名。默认值为 localhost 。
|
port |
应用服务应至少绑定的端口。默认值为 8080 。
|
serverVersion |
要启动的服务器版本,选项包括“1”和“2-alpha”。默认值为“1”。
|
services |
必需。表示一个目录的路径,其中包含 WEB-INF/web.xml 所在的目录。默认值为 build/exploded-app 。 |
startSuccessTimeout |
等待开发应用服务器在后台启动(使用 appengineStart 时)的时间(以秒为单位)。
|
appengineDeploy
task(deploy)
暂存应用并将其部署到 App Engine。
属性 |
说明 |
appEngineDirectory |
.yaml 配置文件(cron、索引等)的位置,用于配置特定部署(appengineDeployCron 等)。对于标准应用,您的 .xml 配置文件在暂存到 .yaml 时会进行转换,并放置在 build/staged-app/WEB-INF/appengine-generated 中。 |
bucket |
用于暂存与部署关联的文件的 Google Cloud Storage 存储桶。如果未指定此参数,则使用应用的默认存储桶。
|
imageUrl |
使用特定的 Docker 映像进行部署。Docker 网址必须来自有效的 Google Container Registry 主机名之一。
|
projectId |
用于此调用的 Google Cloud Platform 项目 ID。
您必须指定 projectId,或者您可以将 GCLOUD_CONFIG 设置为使用 gcloud 配置状态下的项目集。
|
promote |
提升已部署的版本以接收所有流量。默认值为 True。
|
server |
要连接的 App Engine 服务器。您通常不需要更改此值。
|
stopPreviousVersion |
在部署接收所有流量的新版本时,停止以前运行的版本。
|
version |
将由此部署创建或替换的应用版本。如果您未指定版本,系统会为您生成一个版本。 |
全局属性
属性 | 说明 |
tools.cloudSdkHome |
用于配置 gcloud CLI 位置的可选属性。如果未指定此属性,则该插件会自动下载 gcloud CLI。 |
tools.cloudSdkVersion |
用于指定所需 gcloud CLI 版本的可选参数。 |
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-09-04。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-04。"],[[["\u003cp\u003eThe App Engine plugin for Gradle provides several tasks for managing applications in the App Engine standard environment, including deploying, running, and staging.\u003c/p\u003e\n"],["\u003cp\u003eSpecific tasks like \u003ccode\u003eappengineDeployCron\u003c/code\u003e, \u003ccode\u003eappengineDeployDispatch\u003c/code\u003e, etc., allow deploying individual configuration files such as \u003ccode\u003ecron.yaml\u003c/code\u003e, \u003ccode\u003edispatch.yaml\u003c/code\u003e, respectively.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eappengineRun\u003c/code\u003e task runs the local development server, automatically reloading the application if \u003ccode\u003eappengine-web.xml\u003c/code\u003e is changed, eliminating the need for manual restarts.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eappengineStage\u003c/code\u003e task prepares an application directory for deployment, and you can customize its behavior with properties such as \u003ccode\u003ecompileEncoding\u003c/code\u003e, \u003ccode\u003esourceDirectory\u003c/code\u003e, and \u003ccode\u003estagingDirectory\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eappengineDeploy\u003c/code\u003e task stages and deploys the application to the App Engine, and you can configure the deployment with properties such as \u003ccode\u003ebucket\u003c/code\u003e, \u003ccode\u003eprojectId\u003c/code\u003e, and \u003ccode\u003eversion\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# App Engine Gradle Plugin Tasks and Properties\n\nAfter [adding the App Engine\nplugin](/appengine/docs/legacy/standard/java/using-gradle#creating_a_new_project) to\nyour project, you can use the following App Engine-specific Gradle\ntasks for applications in the App Engine standard environment:\n\nTo see a list of all the tasks: \n\n gradle tasks\n\nFor more information on how to set up and use Gradle, see\n[Using App Engine Gradle](/appengine/docs/legacy/standard/java/using-gradle).\n\nTask properties\n---------------\n\nThe contents of the `gradle.build` file are a set of rules to describe your build. It's\nwritten in a domain specific language for describing builds, based on the\n[Groovy language](http://www.groovy-lang.org/).\n\nEach task has associated properties below that you can use. You can specify\nthese properties in the `gradle.build` file using a\n[configuration closure](https://docs.gradle.org/current/userguide/custom_plugins.html#sec:getting_input_from_the_build)\ntask, and properties.\n\nIn the following example:\n\n- The configuration closure for the plugin is `appengine`.\n- The task is `run`.\n- The property, `port`, is set to `8080`.\n\n appengine { // App Engine tasks configuration\n run { // local (dev_appserver) configuration (standard environments only)\n port = 8080 // default\n }\n\n deploy { // deploy configuration\n stopPreviousVersion = true // default - stop the current version\n promote = true // default - & make this the current version\n }\n }\n\nIf you only have to specify a few properties, you can set them in a single\nline: \n\n```java\n appengine.run.port = 8888\n```\n\nSee the following sections for a list of the properties that are available for each task.\n\nappengineStage\n--------------\n\n**task(stage)**\n\nGenerates an application directory for deployment. `appengineStage` is used by\nthe `appengineDeploy` task.\n\nYou can use the following properties:\n\nappengineRun\n------------\n\n**task(run)**\n\nRuns the App Engine development web server. When the server is\nrunning, it continuously checks to determine whether `appengine-web.xml` has\nchanged. If it has, the server reloads the application. This means that you do\nnot need to stop and restart your application because of changes to `appengine-web.xml`.\n\nYou can use the following properties, some of which correspond to the\n[local development server command line flags](/appengine/docs/legacy/standard/java/tools/using-local-server):\n\nappengineDeploy\n---------------\n\n**task(deploy)**\n\nStages and deploys an application to App Engine.\n\nGlobal properties\n-----------------"]]