App Engine provides a Maven plugin that you can use to build and deploy
your app to App Engine. The plugin does not support Enterprise
Application Archive (EAR) projects.
Before you start
Determine if Maven is installed and which version you have by running
the following command:
mvn-v
If Maven is installed, a long string of information beginning with
Apache Maven and followed by a version number such as 3.9.1 will
display.
If you haven't already done so, follow the steps
here
to download the gcloud CLI, create your Google Cloud project, and
initialize your App Engine app.
Install the gcloud CLI app-engine-java component:
gcloudcomponentsinstallapp-engine-java
Adding the App Engine Maven plugin
To use the App Engine Maven plugin, add the following lines to the plugins section in
your project's pom.xml file:
Replace PROJECT_ID with the ID of your Google Cloud project. If
your pom.xml file already
specifies your
project ID, you don't need to include the -Dapp.deploy.projectId property in the
command you run.
The package goal builds and packages your app, and the
appengine:deploy goal
does the following:
Generates a unique version ID for the new version of your app.
Deploys the new version to App Engine.
Routes all traffic to the new version.
Changing the deployment defaults
You can change the default deployment behavior by passing parameters in the
appengine:deploy command. For example, the following command deploys the
service defined in your pom.xml file to a specific Google Cloud project,
assigns a custom version ID to the service, and turns off automatic traffic
routing for the new version:
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-25 UTC."],[[["\u003cp\u003eApache Maven is a build automation tool for Java, and App Engine provides a Maven plugin to build and deploy Java applications to App Engine, although it does not support Enterprise Application Archive (EAR) projects.\u003c/p\u003e\n"],["\u003cp\u003eBefore using the App Engine Maven plugin, ensure you have Maven version 3.9.1 or newer installed, the gcloud CLI, your Google Cloud project, an initialized App Engine app, and the gcloud CLI \u003ccode\u003eapp-engine-java\u003c/code\u003e component installed.\u003c/p\u003e\n"],["\u003cp\u003eThe App Engine Maven plugin can be added to a project's \u003ccode\u003epom.xml\u003c/code\u003e file, and it includes the Jetty Maven plugin, allowing for quick local testing of the application without needing to create a WAR file.\u003c/p\u003e\n"],["\u003cp\u003eTo test the application locally, use the \u003ccode\u003emvn jetty:run\u003c/code\u003e command after packaging the app, and then access it via \u003ccode\u003ehttp://localhost:8080/\u003c/code\u003e, with the ability to shut it down with Control+C.\u003c/p\u003e\n"],["\u003cp\u003eTo build and deploy the application to App Engine, use the \u003ccode\u003emvn package appengine:deploy\u003c/code\u003e command, optionally specifying project ID, custom version, and traffic routing behavior.\u003c/p\u003e\n"]]],[],null,["# Using Apache Maven and the App Engine Plugin\n\n[Apache Maven](http://maven.apache.org/) is a\nbuild automation tool for Java.\n\nApp Engine provides a Maven plugin that you can use to build and deploy\nyour app to App Engine. The plugin does not support Enterprise\nApplication Archive (EAR) projects.\n| **Note:** For information about other ways to build and deploy your app, see [Testing and deploying your app](/appengine/docs/flexible/testing-and-deploying-your-app).\n\nBefore you start\n----------------\n\n1. Determine if Maven is installed and which version you have by running\n the following command:\n\n mvn -v\n\n If Maven is installed, a long string of information beginning with\n `Apache Maven` and followed by a version number such as `3.9.1` will\n display.\n2. If you don't have Maven 3.9.1 or newer installed:\n\n 1. [Download](https://maven.apache.org/download.cgi) Maven 3.9.1 or newer.\n 2. [Install](https://maven.apache.org/install.html) Maven 3.9.1 or newer.\n\n | **Note:** Linux users might need to download Maven instead of using `apt-get install` to install Maven 3.9.1 or newer.\n3. If you haven't already done so, follow the steps\n [here](/appengine/docs/flexible/setting-up-environment)\n to download the gcloud CLI, create your Google Cloud project, and\n initialize your App Engine app.\n\n4. Install the gcloud CLI `app-engine-java` component:\n\n gcloud components install app-engine-java\n\nAdding the App Engine Maven plugin\n----------------------------------\n\nTo use the [App Engine Maven plugin](https://github.com/GoogleCloudPlatform/appengine-plugins/tree/main/app-maven-plugin), add the following lines to the `plugins` section in\nyour project's `pom.xml` file: \n\n \u003cplugins\u003e\n \u003cplugin\u003e\n \u003cgroupId\u003ecom.google.cloud.tools\u003c/groupId\u003e\n \u003cartifactId\u003eappengine-maven-plugin\u003c/artifactId\u003e\n \u003cversion\u003e2.8.1\u003c/version\u003e\n \u003c/plugin\u003e\n \u003cplugin\u003e\n \u003cgroupId\u003eorg.eclipse.jetty\u003c/groupId\u003e\n \u003cartifactId\u003ejetty-maven-plugin\u003c/artifactId\u003e\n \u003cversion\u003e9.4.56.v20240826\u003c/version\u003e\n \u003c/plugin\u003e\n \u003c/plugins\u003e\n\n| **Note:** If there is a newer version of the App Engine Maven plugin, you should upgrade to the [latest version](http://mvnrepository.com/artifact/com.google.cloud.tools/appengine-maven-plugin).\nThe App Engine plugin includes the Jetty Maven plugin, which you can use to test your application quickly without creating a WAR file.\n\n\u003cbr /\u003e\n\nUsing the Jetty Maven plugin to test your app locally\n-----------------------------------------------------\n\nDuring the development phase, you can run and test your app at any time in\nthe development server by invoking the Jetty Maven plugin.\n\nTo run your app in the development server:\n\n1. Build your app if you haven't already done so:\n\n mvn package\n\n2. Change directory to the top level of your project (for example, to `myapp`),\n and run your app by invoking Maven:\n\n mvn jetty:run\n\n3. Wait for the server to start and use your browser to visit\n [`http://localhost:8080/`](http://localhost:8080) to access your app.\n\n4. Shut down the app and the development server by pressing **Control+C**.\n\nBuilding and deploying your app\n-------------------------------\n\nAfter you add the App Engine Maven plugin to your project's `pom.xml`\nfile, you can use the following command to build deploy your app: \n\n```\nmvn package appengine:deploy -Dapp.deploy.projectId=PROJECT_ID\n```\n\nReplace \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e with the ID of your Google Cloud project. If\nyour `pom.xml` file already\n[specifies your\nproject ID](/appengine/docs/flexible/java/maven-reference#appenginedeploy), you don't need to include the `-Dapp.deploy.projectId` property in the\ncommand you run.\n\nThe `package` goal builds and packages your app, and the\n\n[`appengine:deploy` goal](/appengine/docs/flexible/java/maven-reference#appenginedeploy)\n\ndoes the following:\n\n1. Generates a unique version ID for the new version of your app.\n\n2. Deploys the new version to App Engine.\n\n3. Routes all traffic to the new version.\n\nChanging the deployment defaults\n--------------------------------\n\nYou can change the default deployment behavior by passing parameters in the\n`appengine:deploy` command. For example, the following command deploys the\nservice defined in your `pom.xml` file to a specific Google Cloud project,\nassigns a custom version ID to the service, and turns off automatic traffic\nrouting for the new version: \n\n```bash\nmvn appengine:deploy -Dapp.deploy.projectId=PROJECT_ID -Dapp.deploy.version=VERSION_ID -Dapp.deploy.promote=False\n```\n\nYou can also use the `appengine:deploy` command to deploy configuration files,\nsuch as `cron.yaml`, `dispatch.yaml`, and `index.yaml`.\n\nFor more information, see the `appengine:deploy`\n\n[reference](/appengine/docs/flexible/java/maven-reference#appenginedeploy)\n.\n\nWhat's next\n-----------\n\n- Review the [JDK 21 App Engine Maven plugin sample](https://github.com/GoogleCloudPlatform/java-docs-samples/tree/main/appengine-java21/helloworld).\n- Explore the plugin code and report issues on [GitHub](https://github.com/GoogleCloudPlatform/app-maven-plugin).\n- Learn how to specify parameters for tasks by referring to [App Engine Maven Goals and Parameters](/appengine/docs/flexible/java/maven-reference#appenginedeploy)."]]