Getting Started: Setting Up Your Development Environment

Learn how to set up your build environment for app development and deployment to Google App Engine Standard. The supported Java development and build environments are IntelliJ IDEA, Eclipse, Apache Maven, and Gradle.

This guide will show you how to:

  • Install the Google Cloud SDK command-line tool.
  • Install and configure App Engine plugins for Eclipse, IntelliJ, Gradle, and Maven.
  • Create a new App Engine project.
  • Give permission to Cloud Build to enable building and deploying your app.

Installing required SDKs

  1. If you haven't already installed Java SE 8 SDK, install the Java SE 8 Development Kit (JDK).

  2. Install the latest version of the Google Cloud SDK.

    Install Google Cloud SDK

  3. Install the App Engine Java component:

    gcloud components install app-engine-java
    
  4. Authorize your user account:

    gcloud auth application-default login
    
  5. Optionally, to create a service account run gcloud auth activate-service-account --key-file=your_key.json. For more information, see Authorizing Cloud SDK Tools.

Configuring your development environment

Eclipse

Before you begin:

  1. Java EE Developers, sürüm 4.8 veya üzeri için Eclipse IDE'yi yükleyin:

    Tutulmayı İndir

  2. Eclipse için Google Eklentisi yüklüyse GPE prosedürlerinden taşıma işlemini tamamlayın.

Install the plugin:

  1. Yükle düğmesini çalışan Eclipse çalışma alanınıza sürükleyin:

    Çalışan Eclipse çalışma alanınıza sürükleyin.

    Ya da Eclipse içinden Yardım > Eclipse Marketplace ... 'i seçin ve Eclipse için Google Cloud Tools'u arayın.

  2. İstendiğinde Eclipse'i yeniden başlatın.

IntelliJ

Before you begin:

  1. Sign in to your Google Account.

    If you don't already have one, sign up for a new account.

  2. In the Cloud Console, on the project selector page, select or create a Cloud project.

    Go to the project selector page

  3. Projeniz için faturalandırmanın etkinleştirildiğinden emin olun.

    Faturalandırmayı etkinleştirmeyi öğren

  4. Ensure that the following software is installed on your local system:

Install the plugin:

  1. Open IntelliJ IDEA (or any supported JetBrains IDE).
  2. From your plugins marketplace (File > Settings > Plugins or for Mac OS X, IntelliJ IDEA > Preferences > Plugins), search for the 'Cloud Code' plugin and install it.

    You may be prompted to restart your IDE to activate the plugin.

  3. Configure the project JDK:

    1. Open File > Project Structure.
    2. Choose Project Settings > Project.
    3. If the Project SDK is missing, click New... and choose a JDK.

Gradle

  1. Install Gradle v3.4.1 or newer

  2. Install git

Maven

  1. Download Maven 3.5 from the Maven website.

  2. Install Maven 3.5 on your local machine.

Creating a new App Engine project

Eclipse

  1. Google Cloud Platform araç çubuğu düğmesini tıklayın .

  2. Yeni Proje Oluştur > Google App Engine Standart Java Projesi'ni seçin .

  3. Bir Proje adı ve (isteğe bağlı olarak) bir Java paketi girin.

  4. Maven tabanlı bir App Engine projesi oluşturmak için Maven Projesi Olarak Oluştur seçeneğini işaretleyin ve bu proje için koordinatları ayarlamak üzere seçtiğiniz bir Maven Grup Kimliği ve Artefakt Kimliği girin. Grup Kimliği genellikle paket adıyla aynıdır, ancak zorunlu değildir. Artefakt Kimliği genellikle proje adıyla aynı veya buna benzer, ancak olması gerekmez.

  5. İleri'ye tıklayın.

  6. Projede ihtiyacınız olan kütüphaneleri seçin.

  7. Bitir'e tıklayın.

Sihirbaz, IDE'den çalıştırabileceğiniz ve dağıtabileceğiniz basit bir sunucu uygulamasına sahip yerel bir Eclipse projesi oluşturur.

IntelliJ

  1. Choose File > New > Project to display the New Project dialog.

  2. Choose Java in the left panel.

  3. In the Additional Libraries and Frameworks section, check the Google App Engine box for your environment.

    New Java project with 'Google App Engine Standard' selected within Additional Libraries and Frameworks.

  4. Select the additional libraries you want to add to the classpath of your application. The Servlet API is selected by default.

  5. Click Next.

  6. Enter a Project name.

  7. Enter a Project location if you do not want to keep the default.

  8. Update the fields in the More Settings section if you do not want to keep the defaults.

  9. Click Finish.

Gradle

  1. Create a new directory.

  2. Initialize the new project in the created directory:

    gradle init --type java-library;
    mkdir -p src/main/webapp/WEB-INF;
    rm src/main/java/Library.java src/test/java/LibraryTest.java
    

    Gradle will create a skeleton directory structure with two empty classes that are removed in the final rm command.

  3. Add the following to your build.gradle file to add App Engine Gradle tasks, Maven repositories, the App Engine Gradle plugin, dependencies, and task configuration:

    buildscript {      // Configuration for building
      repositories {
        jcenter()      // Bintray's repository - a fast Maven Central mirror & more
        mavenCentral()
      }
      dependencies {
        classpath 'com.google.cloud.tools:appengine-gradle-plugin:2.2.0'
        classpath 'org.akhikhl.gretty:gretty:+'
      }
    }
    
    repositories {   // repositories for Jar's you access in your code
      jcenter()
      mavenCentral()
    }
    
    apply plugin: 'java'
    apply plugin: 'war'
    apply plugin: 'org.akhikhl.gretty'
    apply plugin: 'com.google.cloud.tools.appengine'
    
    dependencies {
      providedCompile 'javax.servlet:javax.servlet-api:3.1.0'
      providedCompile 'com.google.appengine:appengine:+'
    // Add your dependencies here.
    
    }
    
    gretty {
        servletContainer = 'jetty9'  // What App Engine Flexible uses
    }
    
      appengine {
        deploy {   // deploy configuration
          stopPreviousVersion = true  // default - stop the current version
          promote = true              // default - & make this the current version
        }
      }
    
    group = 'com.example.appengine'   // Generated output GroupId
    version = '1.0-SNAPSHOT'          // Version in generated output
    
    sourceCompatibility = 1.8
    targetCompatibility = 1.8

Maven

To create an App Engine App:

  1. Create a new directory.

  2. Initialise the new project in the created directory:

     mvn archetype:generate -Dappengine-version=1.9.59 -Djava8=true -DCloudSDK_Tooling=true -Dapplication-id=your-app-id -Dfilter=com.google.appengine.archetypes:
    
    1. Set -Dappengine-version to the most recent version of the App Engine SDK for Java, and application-id to the ID of your Cloud project.

    2. Set -Djava8=true to deploy the project in the Java 8 runtime.

    3. Set -DCloudSDK_Tooling=true to use Cloud SDK tooling.

  3. When prompted to choose an archetype, choose the value 2 for the App Engine skeleton archetype. This creates an empty project that contains the required directory structure and files.

  4. When prompted for version, press ENTER to select the default most recent version.

  5. When prompted to Define value for property 'groupId', supply the desired namespace for your app; for example, com.mycompany.myapp.

  6. When prompted to Define value for property 'artifactId', supply the project name; for example, myapp.

  7. When prompted to Define value for property 'version', accept the default value.

  8. When prompted to Define value for property 'package', supply your preferred package name (or accept the default). The generated Java files will have the package name you specify here.

  9. When prompted to confirm your choices, accept the default value (Y).

  10. Wait for the project to finish generating, then change directories to the new project directory, for example myapp/.

  11. Add the Cloud SDK-based plugin to your project's pom.xml file.

    <build>
        <plugins>
           [...]
              <plugin>
                <groupId>com.google.cloud.tools</groupId>
                <artifactId>appengine-maven-plugin</artifactId>
                <version>2.2.0</version>
                <configuration>
                    <project>your-project-ID-goes-here</project>
                    <version>1</version>
                </configuration>
              </plugin>
           [...]
        </plugins>
    </build>
    
  12. Specify the target Google Cloud Platform project ID and the service and version in the plugin configuration.

Give permission to Cloud Build

When you deploy your app, App Engine uses Cloud Build to build the app into a container and deploy the container to the runtime. Cloud Build does not have permission to deploy Java 8 apps by default, so you need to give Cloud Build permission to deploy apps in your project.

What's next

Now that your development environment is set up, you can get started developing and deploying Java apps to App Engine.