Using Apache Maven and the App Engine Plugin Stay organized with collections Save and categorize content based on your preferences.
Apache Maven is abuild automation tool for Java.
App Engine provides a Maven plugin that you can use to build and deployyour app to App Engine. The plugin does not support EnterpriseApplication Archive (EAR) projects.
Note: For information about other ways to build and deploy your app,seeTesting and deploying your app.Before you start
Determine if Maven is installed and which version you have by runningthe following command:
mvn-vIf Maven is installed, a long string of information beginning with
Apache Mavenand followed by a version number such as3.9.1willdisplay.If you don't have Maven 3.9.1 or newer installed:
Note: Linux users might need to download Maven instead of usingapt-get installto install Maven 3.9.1 or newer.If you haven't already done so, follow the stepshereto download the gcloud CLI, create your Google Cloud project, andinitialize your App Engine app.
Install the gcloud CLI
app-engine-javacomponent:gcloudcomponentsinstallapp-engine-java
Adding the App Engine Maven plugin
To use theApp Engine Maven plugin, add the following lines to theplugins section inyour project'spom.xml file:
<plugins><plugin><groupId>com.google.cloud.tools</groupId><artifactId>appengine-maven-plugin</artifactId><version>2.8.1</version></plugin><plugin><groupId>org.eclipse.jetty</groupId><artifactId>jetty-maven-plugin</artifactId><version>9.4.56.v20240826</version></plugin></plugins>Using the Jetty Maven plugin to test your app locally
During the development phase, you can run and test your app at any time inthe development server by invoking the Jetty Maven plugin.
To run your app in the development server:
Build your app if you haven't already done so:
mvnpackageChange directory to the top level of your project (for example, to
myapp),and run your app by invoking Maven:mvnjetty:runWait for the server to start and use your browser to visit
http://localhost:8080/to access your app.Shut down the app and the development server by pressingControl+C.
Building and deploying your app
After you add the App Engine Maven plugin to your project'spom.xmlfile, you can use the following command to build deploy your app:
mvn package appengine:deploy -Dapp.deploy.projectId=PROJECT_ID
ReplacePROJECT_ID with the ID of your Google Cloud project. Ifyourpom.xml file alreadyspecifies yourproject ID, you don't need to include the-Dapp.deploy.projectId property in thecommand you run.
Thepackage goal builds and packages your app, and theappengine:deploy goaldoes 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 theappengine:deploy command. For example, the following command deploys theservice defined in yourpom.xml file to a specific Google Cloud project,assigns a custom version ID to the service, and turns off automatic trafficrouting for the new version:
mvnappengine:deploy-Dapp.deploy.projectId=PROJECT_ID-Dapp.deploy.version=VERSION_ID-Dapp.deploy.promote=False
You can also use theappengine:deploy command to deploy configuration files,such ascron.yaml,dispatch.yaml, andindex.yaml.
For more information, see theappengine:deployreference.
What's next
- Review theJDK 21 App Engine Maven plugin sample.
- Explore the plugin code and report issues onGitHub.
- Learn how to specify parameters for tasks by referring toApp Engine Maven Goals and Parameters.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-15 UTC.