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 開發伺服器,然後返回指令列。當此目標執行時,除了 Gradle 會持續處理工作,並在伺服器啟動並執行後結束以外,所有行為都與執行目標相同。
|
appengineStop |
停止執行中的 App Engine 網路開發伺服器。 |
explodeWar |
將 WAR 檔案打散到建構目錄中。 |
如要查看所有工作的清單:
gradle tasks
如要進一步瞭解如何設定及使用 Gradle,請參閱使用 App Engine Gradle 一文。
工作屬性
gradle.build
檔案的內容是用來說明建構的一組規則,其以 Groovy 語言為基礎,採用網域特定語言編寫來說明建構。
每項工作都有如下您可以使用的關聯屬性。您可以使用設定閉包、工作與屬性,在 gradle.build
檔案中指定這些屬性。
在下列範例中:
- 外掛程式的設定閉包為
appengine
。
- 工作是
run
。
- 屬性
port
已設為 8080
。
如果您只需要指定幾個屬性,可以在一行中設定:
appengine.run.port = 8888
如需適用於每項工作的屬性清單,請參閱以下幾節。
appengineStage
task(stage)
針對部署產生應用程式目錄,appengineStage
會由 appengineDeploy
工作使用。
您可以使用以下屬性:
屬性 | 說明 |
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 |
將符合逗號分隔 SUFFIXES 清單的檔案排除在所有 JAR 檔案之外。僅適用於在 App Engine 標準環境中執行的應用程式。 |
sourceDirectory |
這是必要旗標,已編譯的網路應用程式檔案,或爆炸的 WAR 的位置。這會做為暫存來源使用。僅適用於 App Engine 標準環境。預設值為 build/exploded-${gradle-module-name} 。 |
stagingDirectory |
這是必要旗標,用來暫存應用程式的目標目錄。預設值為 build/staged-app 。 |
appengineRun
task(run)
執行 App Engine 開發網路伺服器。當伺服器正在執行時,會持續檢查確認 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、index 等) 的位置,設定的特定部署作業 (appengineDeployCron 等) 將從這個位置部署。若為標準應用程式,您的 .xml 設定檔會在暫存期間轉換為 .yaml ,並放在 build/staged-app/WEB-INF/appengine-generated 中。 |
bucket |
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 版本的選用參數。 |
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間: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"]],["上次更新時間: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-----------------"]]