Skip to content

Instantly share code, notes, and snippets.

@ribrdb
Created July 21, 2010 22:51
Show Gist options
  • Select an option

  • Save ribrdb/485260 to your computer and use it in GitHub Desktop.

Select an option

Save ribrdb/485260 to your computer and use it in GitHub Desktop.
begin
require 'ant'
rescue
puts 'This Rakefile requires JRuby. Please use jruby -S rake.'
exit 1
end
require 'mirah/appengine_tasks'
require 'rake/clean'
appengine_app :app, 'app', '' => ["WEB-INF/lib/application.jar",
"WEB-INF/lib/dubious.jar",
]
Duby.dest_paths << 'build'
Duby.source_paths << 'lib'
Duby.compiler_options << '--classpath' << File.expand_path('build')
CLEAN.include('build')
CLOBBER.include("WEB-INF/lib/*.jar", 'WEB-INF/appengine-generated')
def class_files_for files
files.map do |f|
explode = f.split('/')[1..-1]
explode.last.gsub!(/(^[a-z]|_[a-z])/) {|m|m.sub('_','').upcase}
explode.last.sub! /\.(duby|java|mirah)$/, '.class'
'build/' + explode.join('/')
end
end
APP_SRC = Dir["app/**/{*.duby,*.mirah}"]
APP_CLASSES = class_files_for APP_SRC
APP_MODEL_CLASSES = APP_CLASSES.select {|app| app.include? '/models' }
APP_CONTROLLER_CLASSES = APP_CLASSES.select {|app| app.include? '/controllers' }
TEMPLATES = Dir["app/views/**/*.erb"]
LIB_MIRAH_SRC = Dir["lib/**/*.duby"]
LIB_JAVA_SRC = Dir["lib/**/*.java"]
LIB_SRC = LIB_MIRAH_SRC + LIB_JAVA_SRC
LIB_CLASSES = class_files_for LIB_SRC
STDLIB_CLASSES= LIB_CLASSES.select{|l|l.include? 'stdlib'}
CLASSPATH = [AppEngine::Rake::SERVLET, AppEngine::SDK::API_JAR].join(":")
file "build/dubious/Inflection.class" => :'compile:java'
file "build/dubious/ScopedParameterMap.class" => :'compile:java'
file "build/dubious/ActionController.class" => ["build/dubious/Params.class", "build/dubious/FormHelper.class", "build/dubious/AssetTimestampsCache.class"]
file "build/dubious/Inflections.class" => "build/dubious/Inflection.class"
file "build/dubious/FormHelper.class" => ["build/dubious/Inflections.class", *STDLIB_CLASSES]
file "build/dubious/Params.class" => "build/dubious/ScopedParameterMap.class"
APP_CONTROLLER_CLASSES.each do |f|
file f => APP_MODEL_CLASSES + TEMPLATES
end
APP_CLASSES.each do |f|
file f => LIB_CLASSES
end
directory 'build'
namespace :compile do
task :app => [:dubious, "WEB-INF/lib/application.jar"]
task :dubious => "WEB-INF/lib/dubious.jar"
task :java => 'build' do
ant.javac :srcdir=>'lib', :destdir=>'build', :classpath=>CLASSPATH
end
end
desc "compile app"
task :compile => 'compile:app'
file "WEB-INF/lib/dubious.jar" => LIB_CLASSES do
includes = LIB_CLASSES.map {|d|d.sub 'build/',''}.join(',')
ant.jar :destfile=>"WEB-INF/lib/dubious.jar", :basedir=>'build',
:includes=>includes
end
file "WEB-INF/lib/application.jar" => APP_CLASSES do
includes = APP_CLASSES.map {|d|d.sub 'build/',''}.join(',')
ant.jar :destfile=>"WEB-INF/lib/application.jar", :basedir=>'build',
:includes=>includes
end
task :default => :server
# TODO: I'm not sure where the correct place to run this is.
# sh 'script/environment.rb'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment