2016-07-20

Migration from Google App Engine to Flexible Environment

Migration

Google App Engine is great since it's reliable and have tons of services free to use. Compared to a platform like Heruko, you get search, database, image and other services for free. But as a javaite, it's unfortunate that it only supports Java 7. The only way to move forward is to migrate to Flexible Environment. But be aware, not all services can migrate!

Start: App Engine

Let's start with a simple App Engine Maven project and then migrate it.

Prerequisites

Use the following guide to install Java 7 SDK and Maven.

Create Artifact

Use Maven to create the simple appengine skeleton artifact.
  1. Run
    $ mvn archetype:generate -Dappengine-version=1.9.38 -Dapplication-id=whatever -Dfilter=com.google.appengine.archetypes:
  2. Select "1"
    1: remote -> com.google.appengine.archetypes:appengine-skeleton-archetype (A skeleton application with Google App Engine)
  3. Select "6"
    6: 2.1.0-1.9.38
  4. Enter group id (same as your Java package name for the project)
    Define value for property 'groupId':
  5. Enter your name for your project
    Define value for property 'artifactId': :
  6. Enter first version
    Define value for property 'version':  1.0-SNAPSHOT:
  7. Enter Java package (same as group id)
    Define value for property 'package':
  8. Enter gcloud version (find latest here)
    Define value for property 'gcloud-version': 2.0.9.111.v20160527
  9. Confirm your selection
     Y:
Maven have now created an App Engine project in a subfolder. Start it with $ mvn appengine:devserver
Notice the layout and the few files needed.
Simple layout with few files

Migration: Flexible Environment

Let's go for Flexible Environment and Java 8!

Prerequisites

  • Install Java 8 SDK and never look back!
    Note: that App Engine uses Jetty which need Java 7 to work with JSP. If you install Java 8 it will be difficult for you to run your old App Engine projects.
  • Install Google Cloud SDK. Make sure Python is on path after installation!
    https://cloud.google.com/sdk/
  • Install the app-engine component to GCloud
    gcloud components install app-engine-java
    https://cloud.google.com/appengine/docs/flexible/java/maven

Migration

Follow the steps in the following guide.
  1. Add the following line in appengine-web.xml
    <vm>true</vm>
  2. Add the following two plugins in pom.xml.
    1. The first one to be able to run with GCloud maven goals
    2. And the second to set Java 8 compilation.
  3. <plugin>
       <groupId>com.google.appengine</groupId>
       <artifactId>gcloud-maven-plugin</artifactId>
       <version>2.0.9.106.v20160420</version>
    </plugin>
  4.       <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <version>3.3</version>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
              <source>1.8</source>
              <target>1.8</target>
            </configuration>
          </plugin>
  5. Run with
  6. $ mvn gcloud:run

Inga kommentarer:

Skicka en kommentar