Monday, 16 February 2015

Using Maven with Google App Engine GAE

Introduction
Maven is a popular open source build tool for enterprise Java projects, designed to take much of the hard work out of the build process.

Lets get started!

Firstly, we have to confirm if maven is installed on the development system by entering this command on the console.

mvn -version

This will display the maven home path, the java home, the java version, maven version and some other information as shown in the image below:
mvn -version
Note: the maven version must be 3+

Lets create our application directory, I prefer to create mine not far from the root directory

cd \dev
mkdir samplegae
cd samplegae

Our application directory is samplegae.

Invoke the below Maven command

mvn archetype:generate -Dappengine-version=1.9.17 -Dfilter=com.google.appengine.archetypes:

This might take some time depending on the internet speed. The image show the response:

To continue we'll have to choose our preferred archetype between 1 - 5. You can choose option 1 or 2 if you want to develop from scratch. Option 3 will create a sample guestbook application with minimal codes which can be easily be deleted. For this tutorial, lets choose option 3 and press enter.

Then press enter to choose 7 which is the default selected and latest version of the guestbook-archetype.

Then supply the desired namespace for the app, e.g. com.japharr.samplegae, the artifactId, e.g. samplegae. Press enter to choose the default version, then input the package name e.g. com.japharr.samplegae. 

Since we don't have out app id, we can enter Y to accept the default "your-app-id". The image below depict the whole processes: 

Change directory to the application directory

cd samplegae

Invoke the below command to build the project

mvn clean install



Invoke the below command to deploy the application on a test server

mvn appengine:devserver


Open your browser and point it to localhost:8080


That's all, you're done