Getting Started With Project Sprouts and IntelliJ IDEA - Part 1

Written by

In part one I will guide you on how to get the basics setup with Project Sprouts and IntelliJ IDEA and end by running your rake task.  I am demonstrating these examples on Mac OS X, however there is nothing stopping you completing this on your own OS. Install RVM I advise installing Ruby Version Manager (RVM) as there are potential versions of specific ruby gems that Sprouts uses which will need to be configured.  RVM allows you to have multiple ruby environments to allow for this flexibility in work flow. Once you have followed the instructions to install RVM go ahead and install, use Ruby 1.9.2:

1
2
$ rvm install 1.9.2
$ rvm use 1.9.2

To check which version of ruby your using and its installation location you can use the following:

1
2
$ ruby -v
$ which ruby

To check the the version of Sprouts you have installed for the currently loaded Ruby version (also lists all other installed gems):

1
$ gem list

My personal preference is to then set this specific version to be the default ruby i.e. when I open Terminal this is the version that is used:

1
$ rvm --default use 1.9.2

To switch back simply use:

1
$ rvm use system

Install Project Sprouts Now we have our ruby environment setup we can install Project Sprouts to a specific version of ruby.  Follow the instructions on the Project Sprouts website: Getting Started and go create a project shown in the installation example, have a little play familiarising yourself with Project Sprouts. If you installed everything correctly you should see flashsdk (1.0.27.pre) and sprout (1.1.11.pre): When you run:

1
$ gem list

Install IntelliJ IDEA Download and install IntelliJ IDEA 10.5 (other versions will be fine running this example). Create a new AS3 project Now this is an area I am trying to refine into a slightly smoother process by removing one of the steps, but for now roll with me.

  1. Open IntelliJ and File > Create Command-line Launcher then follow the instructions.  This will enable us to launch IntelliJ in the current shell session and therefore target the specific RVM ruby version using IntelliJ’s command-line tool (super thanks to @devboy_org for this tip).

Create a new IntelliJ Project

For now this is not the ideal process and I am working on a better solution.  Step one is only applicable if your using RVM and not your system default installation of Ruby.  I have found two ways to set up a project, the first is the quickest and easiest and I thought I would show another optional alternative (Option Two below).

OPTION ONE

Step One:

1: If not your default then using RVM set the specific ruby version where you installed Project Sprouts

1
rvm use 1.9.2

2: Open IntelliJ IDEA from command line

1
idea .

You will see a warning from IntelliJ basically stating there is no project setup.

Step Two:

1: Now go ahead and create a Flex/ActionScript project as per normal named SomeProject. 2: In IntelliJ go to Tools > Run Command or use the hot keys (for mac it’s) SHIFT CMD X to open the Command Line Tools window and run the following command to navigate up to the projects parent directory:

1
cd ../

3: If you created a Flex project then bring up the command window and type:

1
sprout-flex SomeProject

else if ActionScript:

1
sprout-as3 SomeProject

4: In the command window navigate into your project folder:

1
cd SomeProject

5: Install dependencies

1
bundle install

OPTION TWO

Basically its a two step process where you first create a Flex/Actionscript project in IntelliJ as shown below and the secondly have to run the Project Sprouts generator for either a new as3 or flex project.  My future aim is to essentially create the IDEA project files using Project Sprouts at the same time as creating a new flex/as3 project and then auto load IntelliJ using the command-line launcher, all in one hit (similar to what is currently available for Maven Plugin)!  If anyone can help out pointing me in the right direction for generating IDEA files using rake then I would appreciate the help?

Step One:

Open IntelliJ and follow the below screen shots:

1: Create a new project from scratch

2: Give your project a name

3: Don’t bother creating a src directory as we can leave our Project Sprouts generator to do that

4: Define your module Flex SDK and finish

Step Two:

Open a new Terminal window and cd to where you created your new project:

1: Generate the project using sprouts

1
sprout-as3 SomeProject

2: Move into the project directory

1
cd SomeProject

3: Install dependencies

1
bundle install

4: Open in IntelliJ IDEA

1
idea .

Confirm that all our project files are in place!

Compile and run the project

For this tutorial I am going to show one particular method to run the project rake file. This is the simplest approach but if you have used RVM you must ensure you loaded the project in IntelliJ using the command-line launcher.

In IntelliJ go to Tools > Run Command or use the hot keys (for mac it’s) SHIFT CMD X to open the Command Line Tools window and either type rake or rake test and hit Enter. You should hopefully now see your rake task being run and either the swf with your project or the swf with an ASUnit test runner.

NOTE

Versions used for this example:

  • asunit4 (4.2.3.pre)
  • bundler (1.0.14)
  • flashsdk (1.0.29.pre)
  • rake (0.9.2)
  • rubygems-update (1.8.5)
  • rubyzip (0.9.4)
  • sprout (1.1.15.pre)

Comments