This blog describes how to use Gaelyk version 0.5.6 in IntelliJ on a Mac OS X environment.

We are going to use the Gaelyk template project and show how to customize IntelliJ in order to deploy the application both locally and on the Cloud.

My environment

My environment is composed of the following software:

Create your GAE account

In order to be able to deploy an application on Google App Engine (GAE) , you have first to create an account.

The GAE account is free to start.

Check the GAE web site.

If you already have a Google Apps account, sign in using the following URL:

https://appengine.google.com/a/<YOURDOMAIN.COM>/

Install GAE (Google App Engine)

The installation of GAE is quite easy.

You have to download the Java SDK of GAE and extract it in one of your folders, as illustrated below:

$ cd /usr/share
$ sudo unzip /tmp/appengine-java-sdk-1.3.8.zip
...
$ sudo ln -s appengine-java-sdk-1.3.8 appengine

Create the Gaelyk project

We are going to create a Gaelyk project labeled SampleGaelyk.

A good starting point of a Gaelyk project is to start from the template project that contains all required artifacts.

So, let’s start …

Create a project folder where you will extract the Gaelyk template project, as illustrated below:

$ cd ~/Projects
$ mkdir SampleGaelyk
$ cd SampleGaelyk
$ unzip /tmp/gaelyk-template-project-0.5.6.zip

Define path to GAE SDK

The Gaelyk project provides a “build.groovy” file that allows you to build java and Groovy files located under the src folder.

Even if the sample project we describe does not contain any source code to be compiled in this way, it is better to proceed with this configuration step for your future development.

The building process will require you to define the APPENGINE_HOME environment variable to locate the GAE SDK installed on your system.

To let IntelliJ know about this environment variable, it is required to set the information on the environment.plist file.

For more information on environment.plist, check this link.

From your home folder, open the Properly List Editor to edit the environment.plist file as illustrated here below:

$ cd ~
$ open .MacOSX/environment.plist

From the Property List Editor, add the new property APPENGINE_HOME and provide the path where the GAE SDK has been installed (see above):

Save your change and close the window.

The changes will take effect during the log in. So, log out and then log back in to the system.

Open the project

Start IntelliJ and create a new project from existing sources:

Select the project folder SampleGaelyk we have created above:

Click “Next” to keep the default values until the end of the “Wizard”.

Configure the project

This step is required before building and uploading the project to GAE.

First of all, we have to add the support for the Groovy Framework.

Select the project and open the Add Framework Support entry:

Select Groovy and keep Existing SDK as the Gaelyk template project is delivered with the Groovy library.

Then, expand the drop-down to choose the SDK of Groovy 1.7.5:

Click on OK. Your project has now the Groovy support.

Now, we are ready to proceed with the configuration of the project.

Select your project and open the Module Settings:

Configure the Google App Engine facet to select the path of the GAE SDK (see below) and to enter your GAE account:

Apply your changes.

Now, select the Web facet entry and click on “Create Artifact” to create the Web facet resources in an artifact:

The artifact is created and we have to set the “Build on make” option:

Click on OK to apply the changes.

Create a Run configuration

To run locally the project, we are going to create a configurations:

Add the new configuration “Google AppEngine Dev Server“.

Enter a name for the configuration. We choose “Local GAE“:

Click on OK.

We are ready to run the application.

Run locally

Select the “Local GAE” configuration and click on the Run icon:

The project is build and started locally.

The local GAE is available at : http://localhost:8080/

In addition to the display of the current date/time, you can check the file upload available at: http://localhost:8080/upload

Create and define the GAE application

To deploy the project on the Cloud, we need to have a target application already created on GAE.

As of the day this post is written, I find the way to create a new application very confusing. I have experienced the same trouble as described in this message.

I found a way that works for me:

To create a new GAE application, I use the URL https://appengine.google.com (using my Google Apps account)

To view and manage my GAE applications, I use the URL https://appengine.google.com/a/<YOURDOMAIN.COM>/

Before deploying the project, we need to change the application name in the App Engine’s /war/WEB-INF/appengine-web.xml:

<application>myappid</application>
<version>1</version>

The Version is used to deploy different versions of your project to GAE.

Change the “application” element to set the application name you define in your GAE environment.

Based on our illustration, we will set the following value:

<application>sandgaelyk</application>
<version>1</version>

Deploy the project to GAE

Back to IntelliJ, we are ready to build and to deploy the project to GAE.

From the Tools menu, select the option “Upload App Engine Application”:

If you check the Run windows, you will able to follow the upload process:

The upload is completed.

It is time to check our application in the Cloud !

Run on the Cloud

To run the application, you can proceed in two ways:

  1. from the application list of your GAE account
  2. from the application URL

The option 1 allows to ensure that the application is properly deployed and makes it possible for you to manage your settings:

To start the application, you have to click on the application’s version:

The option 2 consists in invoking the application from its URL:

http://sandgaelyk.appspot.com/

Now, your application is working as it does locally.

Sure ?

Not really …

Just try to open the upload page:

http://sandgaelyk.appspot.com/upload

If you have created a brand new GAE application, you should receive a http 500 Server error:

Before starting to complain about Gaelyk, let’s check GAE if we can find any log.

From GAE, display the list of applications and select the application on which you have deployed the project:

On the dashboard, locate the Errors area and select the URI that causes the problem (/upload):

The Errors page displays information such as the list of recorded records:

Expand the most recent entry:

Here’s the problem:

The Blobstore API will be enabled for this application once billing has been enabled in the admin console.

We are not living in a free (free as a beer) world!

Without entering into the details, we can say that the billing of GAE is very flexible and allows you to define a MAX daily budget.

As we are in a Cloud, you will only be charged for the resources you used.

Set the billing

To set the billing of your application, go to left right side and click on Billing Settings:

The Billing Settings show that the application is configured with a free quota levels:

When you enable the Billing, you can define the max daily budget:

Proceed with the checkout.

It is too early to test your application until the Billing process is fully activated.

To check the status, go back to the Billing Settings page:

It is also interesting to check the Billing History page:

Here the Billing process is successful.

Open the upload page to ensure that the feature is working as expected:

http://sandgaelyk.appspot.com/upload

Conclusion

I hope this page will help many of you to discover Gaelyk/GAE with IntelliJ.

The method described above is probably not the most appropriate, but it works for me.

We can also expect that in near future JetBrains will decide to fully support the Gaelyk framework on IntelliJ IDEA.

For that purpose, check the following page: http://youtrack.jetbrains.net/issue/IDEA-58797

References

This content is published under the Attribution-Noncommercial-Share Alike 3.0 Unported license.