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.
- Run
$ mvn archetype:generate -Dappengine-version=1.9.38 -Dapplication-id=whatever -Dfilter=com.google.appengine.archetypes: - Select "1"
1: remote -> com.google.appengine.archetypes:appengine-skeleton-archetype (A skeleton application with Google App Engine) - Select "6"
6: 2.1.0-1.9.38 - Enter group id (same as your Java package name for the project)
Define value for property 'groupId': - Enter your name for your project
Define value for property 'artifactId': : - Enter first version
Define value for property 'version': 1.0-SNAPSHOT: - Enter Java package (same as group id)
Define value for property 'package': - Enter gcloud version (find latest here)
Define value for property 'gcloud-version': 2.0.9.111.v20160527 - 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.
- Add the following line in appengine-web.xml
<vm>true</vm>
- Add the following two plugins in pom.xml.
- The first one to be able to run with GCloud maven goals
- And the second to set Java 8 compilation.
<plugin> <groupId>com.google.appengine</groupId> <artifactId>gcloud-maven-plugin</artifactId> <version>2.0.9.106.v20160420</version> </plugin>
<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>
- Run with
- $ mvn gcloud:run
Inga kommentarer:
Skicka en kommentar