The way to your IT projects
Using Gaelyk in IntelliJ on Mac OS X
Oct 20th
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:
- Mac OS X 10.6.4
- JDK 1.6.0_22
- IntelliJ IDEA 9.0.3
- Groovy 1.7.5 (bundled with Gaelyk 0.5.6)
- Gaelyk template project 0.5.6 (download)
- Google App Engine SDK for Java 1.3.8 (download)
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:
- from the application list of your GAE account
- 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
- Gaelyk web site
- Blog of Søren Glasius
This content is published under the Attribution-Noncommercial-Share Alike 3.0 Unported license.
| Print article | This entry was posted by Said on October 20, 2010 at 12:31 am, and is filed under Technology. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |


























about 1 year ago
Thanks for the write-up. When you start your app on the command line you are able to change the contents of Groovlets/Groovy templates and see the modifications immediately without restarting your dev server. I tried to make this work in IntelliJ but wasn’t able to. Any ideas how to make this work?
Ben
about 1 year ago
Hi Benjamin
The reason why IntelliJ is not able to detect and to hot deploy your changes is because by default the generated Artifacts uses an “out” folder.
This means that when you run your deployment, IntelliJ builds and generates your project into the “out” folder as another “war exploded” archive.
When you run your server locally, Jetty uses the application found in the “out” folder while your sources are located in another folder (“war” by default).
You can avoid this situation by proceeding as describe below:
- Select your project and right-click
- Select “Module Settings”
- From the left side (Project Settings), select “Artifacts”
- On the “Output directory” field, change the folder to select the one where is located your sources:
example: /opt/SandBox/workspace/Gaelyk/MyGaelykProject/war
- Disable the option “Build on make”
Now, you should be able to run locally your application, to update your files and to see the modifications without restarting the server.
I hope this will help you to solve your issue.
Said
about 1 year ago
Perfect, that’s what I was looking for.
Thanks,
Ben