Class: AppEngine::Rake::AppEngineTask
- Inherits:
-
Rake::Task
- Object
- Rake::Task
- AppEngine::Rake::AppEngineTask
- Defined in:
- lib/dubious_tasks.rb
Instance Method Summary collapse
- #api_jar ⇒ Object
- #app_yaml ⇒ Object
- #app_yaml_timestamp ⇒ Object
- #check_for_updates ⇒ Object
- #init(src, war) ⇒ Object
-
#initialize(*args, &block) ⇒ AppEngineTask
constructor
A new instance of AppEngineTask.
- #real_prerequisites ⇒ Object
- #update ⇒ Object
- #webinf_classes ⇒ Object
- #webinf_lib ⇒ Object
- #webinf_lib_jars ⇒ Object
Constructor Details
#initialize(*args, &block) ⇒ AppEngineTask
Returns a new instance of AppEngineTask.
18 19 20 21 |
# File 'lib/dubious_tasks.rb', line 18 def initialize(*args, &block) super AppEngineTask.tasks << self end |
Instance Method Details
#api_jar ⇒ Object
121 122 123 |
# File 'lib/dubious_tasks.rb', line 121 def api_jar File.join(webinf_lib, File.basename(APIS)) end |
#app_yaml ⇒ Object
109 110 111 |
# File 'lib/dubious_tasks.rb', line 109 def app_yaml @war + '/WEB-INF/app.yaml' end |
#app_yaml_timestamp ⇒ Object
103 104 105 106 107 |
# File 'lib/dubious_tasks.rb', line 103 def if File.exist?(app_yaml) File.mtime(app_yaml) end end |
#check_for_updates ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/dubious_tasks.rb', line 70 def check_for_updates @update_thread = Thread.new do # Give the server time to start next_time = Time.now + 5 until @done sleep_time = next_time - Time.now sleep(sleep_time) if sleep_time > 0 next_time = Time.now + 1 update end end end |
#init(src, war) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/dubious_tasks.rb', line 23 def init(src, war) @src = src @war = war unless $CLASSPATH.include?(webinf_classes) $CLASSPATH << webinf_classes end webinf_lib_jars.each do |jar| $CLASSPATH << jar unless $CLASSPATH.include?(jar) end Mirah.source_paths << src Mirah.dest_paths << webinf_classes directory(webinf_classes) directory(webinf_lib) file_create api_jar => webinf_lib do puts 'Copying api jars' cp APIS, api_jar end task :server , :address , :port , :needs => [name] do |t, args| args.with_defaults(:address => '0.0.0.0', :port => '8080') check_for_updates args = [ 'java', '-cp', TOOLS, 'com.google.appengine.tools.KickStart', 'com.google.appengine.tools.development.DevAppServerMain', "--address=#{args.address}", "--port=#{args.port}", @war] system *args @done = true @update_thread.join end desc "publish to appengine" task :upload => ['compile:app', name] do Java::ComGoogleAppengineToolsAdmin::AppCfg.main( ['update', @war].to_java(:string)) end enhance([api_jar]) end |
#real_prerequisites ⇒ Object
66 67 68 |
# File 'lib/dubious_tasks.rb', line 66 def real_prerequisites prerequisites.map {|n| application[n, scope]} end |
#update ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/dubious_tasks.rb', line 83 def update begin = @last_app_yaml_timestamp ||= needed_prerequisites = real_prerequisites.select {|r|r.needed?} needed_prerequisites.each {|dep| dep.execute } unless needed_prerequisites.empty? && == @last_app_yaml_timestamp begin open('http://localhost:8080/_ah/reloadwebapp') @last_app_yaml_timestamp = rescue OpenURI::HTTPError end end rescue Exception puts $!, $@ end end |
#webinf_classes ⇒ Object
113 114 115 |
# File 'lib/dubious_tasks.rb', line 113 def webinf_classes @war + '/WEB-INF/classes' end |
#webinf_lib ⇒ Object
117 118 119 |
# File 'lib/dubious_tasks.rb', line 117 def webinf_lib @war + '/WEB-INF/lib' end |
#webinf_lib_jars ⇒ Object
125 126 127 |
# File 'lib/dubious_tasks.rb', line 125 def webinf_lib_jars Dir.glob(webinf_lib + '/*.jar') end |