Stay organized with collections Save and categorize content based on your preferences.
Gradle is an open-source build automation tool focused on flexibility and performance. App Engine provides a Gradle plugin that you can use to build and deploy your app to App Engine. The code sample demonstrates how to configure the build.gradle
file to add App Engine Gradle tasks, Maven repositories, App Engine Gradle plugin, and dependencies.
If you haven't already done so, follow the steps in this guide to download the gcloud CLI, create your Google Cloud project, and initialize your App Engine app.
Install the gcloud CLI app-engine-java
component:
gcloud components install app-engine-java
You can create a new Gradle project from scratch using the shell. Alternatively, to try out the plugin, you can download, run locally, and deploy the hello world project.
To create a new project:
Create a new directory and navigate to it.
To initialize a new project:
Run gradle init
:
gradle init --type java-application
You'll be asked to answer questions:
Create the WEB-INF
folder:
mkdir -p app/src/main/webapp/WEB-INF
Create the appengine
folder:
mkdir -p app/src/main/appengine
Remove the stub files generated by gradle init
:
rm ./app/src/main/java/org/example/App.java ./app/src/test/java/org/example/AppTest.java
Add the following to your app/build.gradle
file to add App Engine Gradle tasks, Maven repositories, the App Engine Gradle plugin, dependencies, and task configuration:
You also need to add the following files to your project, using a text editor or integrated development environment (IDE):
app/src/main/appengine/app.yaml
app/src/main/webapp/WEB-INF/web.xml
(unless your app uses Servlet 3.1 annotations)See Set up your development environment for an overview of a Java App Engine project.
Testing your application with the development serverTo access Google resources from your project when running locally, set the application default credentials by running:
gcloud auth application-default login
Change to the root of your application directory.
During the development phase, you can run and test your application at any time in the development server by invoking Gradle:
gradle jettyRun
Alternatively, you can run Gradle without installing it by using the Gradle wrapper.
Wait for the server to start. The server is started with your application running when you see a message similar to this:
:prepareInplaceWebAppFolder :createInplaceWebAppFolder :compileJava :processResources UP-TO-DATE :classes :prepareInplaceWebAppClasses :prepareInplaceWebApp :jettyRun 17:40:05 INFO Jetty 9.2.15.v20160210 started and listening on port 8080 17:40:05 INFO runs at: 17:40:05 INFO http://localhost:8080/
See your app running at http://localhost:8080
.
To learn more about the Gretty plugin, see Gretty Configuration and Gretty tasks.
Deploy your applicationTo deploy your application:
gradle appengineDeploy
The appengineDeploy
task and all other Gradle tasks have associated properties that you can use. For a complete list of tasks and properties, refer to App Engine Gradle Tasks and Properties.
Gradle provides a mechanism to download and run the required version of Gradle without installation:
Linux/macOSChange to the sample code directory.
Run gradlew:
./gradlew jettyRun
Change to the sample code directory.
Run gradlew:
./gradlew.bat jettyRun
Additional information on Gradle can be found in App Engine Gradle Tasks and Properties.
What's nextExcept as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-07 UTC.
[[["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-07 UTC."],[[["Gradle, an open-source build automation tool, is used with an App Engine plugin to build and deploy apps to App Engine."],["Setting up a new Gradle project involves initializing the project, creating necessary folders (`WEB-INF`, `appengine`), and modifying the `build.gradle` file to include App Engine configurations, repositories, and dependencies."],["The `build.gradle` file configures settings like build repositories, plugin dependencies, Java version compatibility, Gretty plugin details, and App Engine deployment settings."],["Local testing of the application can be done by running `gradle jettyRun` in the project's root directory, and the app can then be viewed at `http://localhost:8080`."],["Deploying the application to App Engine involves running the command `gradle appengineDeploy`, which utilizes the configured settings within the `build.gradle` file."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4