public
Description: Project Sprouts is an open-source, cross-platform project generation and configuration tool for ActionScript 2, ActionScript 3, Adobe AIR Flash and Flex projects
Home | Edit | New

Example Rakefile (ActionScript 3.0)

In an effort to illuminate what our TaskHelpers do for us, this example rakefile should help people that want to create their own custom tasks.

The documentation for the features used here are as follows:

The following file should build against a new project created with:

sprout -n as3 MyProject

The following tasks will be available:

rake # will execute debug
rake test
rake debug
rake deploy
rake cruise

Copy the following into rakefile.rb

require "sprout"
sprout "as3"

default_size = "930 550"
project_name = "MyProject"

##################################
# Define Debug Tasks:

debug_output = "bin/#{project_name}-debug.swf"
debug_input = "src/#{project_name}.as"

desc "Compile the #{debug_output} file"
mxmlc debug_output do |t|
  t.input = debug_input
  t.default_size = default_size
  t.default_background_color = "#FFCC00"
  t.source_path << "src"
  t.source_path << "assets"
end

desc "Launch the #{debug_output} file"
flashplayer :debug => debug_output do |t|
  t.swf = debug_output
end

##################################
# Define Deploy Tasks:

deploy_output = "bin/#{project_name}.swf"
deploy_input = "src/#{project_name}.as"

desc "Compile the #{deploy_output} file"
mxmlc deploy_output do |t|
  t.optimize = true
  t.input = deploy_input
  t.default_size = default_size
  t.default_background_color = "#333333"
  t.source_path << "src"
  t.source_path << "assets"
end

desc "Launch the #{deploy_output} file"
flashplayer :deploy => deploy_output do |t|
  t.swf = deploy_output
end

##################################
# Define Test Tasks:

test_output = "bin/#{project_name}Runner.swf"
test_input = "src/#{project_name}Runner.as"

library :asunit3

desc "Compile the #{test_output} file"
mxmlc test_output => :asunit3 do |t|
  t.input = test_input
  t.default_size = "1000 600"
  t.default_background_color = "#333333"
  t.source_path << "src"
  t.source_path << "assets"
  t.source_path << "test"
  t.source_path << "lib/asunit3"
end

desc "Launch the #{test_output} file"
flashplayer :test => test_output do |t|
  t.swf = test_output
end

##################################
# Define Cruise Task:

cruise_output = "bin/#{project_name}XMLRunner.swf"
cruise_input = "src/#{project_name}XMLRunner.as"

# This is identical to test task, but with
# debug turned on...
desc "Compile the #{cruise_output} file for CI"
mxmlc cruise_output => :asunit3 do |t|
  t.input = cruise_input
  t.debug = true
  t.default_size = "1000 600"
  t.default_background_color = "#333333"
  t.source_path << "src"
  t.source_path << "assets"
  t.source_path << "test"
  t.source_path << "lib/asunit3"
end

desc "Compile and run the test harness for CI"
fdb :cruise => cruise_output do |t|
    t.kill_on_fault = true
    t.file = cruise_output
    t.run
    t.continue
end

##################################
# set up the default rake task
task :default => :debug

Last edited by lukebayes, Sat May 09 10:50:35 -0700 2009
Home | Edit | New
Versions: