Module: Chrysalis::TaskManager
- Defined in:
- lib/chrysalis/manifest.rb
Overview
Manages tasks synthesized by Chrysalis.
Chrysalis synthesizes any tasks into an all: namespace. When executing a task in this namespace, Chrysalis will retrieve any required dependencies and execute the task on them.
Graph algorithms are used to ensure that task execution is done in the correct order. Tasks are guaranteed to be executed on dependencies before being executed on any dependents.
For example, if a build
task is declared, then an all:build
task will be synthesized. Executing rake all:build will first retrieve dependencies, execute build upon them, and then invoke the main project’s build task.
Constant Summary collapse
- @@tasks =
[]
Class Method Summary collapse
-
.synthesize_task(name, comment) ⇒ Object
Synthesizes a task into the all: namespace.
Class Method Details
.synthesize_task(name, comment) ⇒ Object
Synthesizes a task into the all: namespace.
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/chrysalis/manifest.rb', line 135 def self.synthesize_task(name, comment) # Don't synthesize tasks "all:*", "project:*", or "retrieve" tasks. These # tasks are specific to Chrysalis, and only useful in the context of the # main project. if name.begin?('all:') || name.begin?('project:') || name.eql?('retrieve') return end if !@@tasks.include?(name) rake_namespace :all do rake_task name => "^retrieve" rake_desc "Invoke #{name} task, including dependencies." rake_task name do order = Chrysalis::Manifest.instance[:main].task_exec_order order.delete(:main) order.each do |url| proj = Chrysalis::Manifest.instance[url] if proj.task?(name) cur_dir = FileUtils.pwd FileUtils.cd(proj.working_copy.path) puts "" puts "Invoking #{name} in #{proj.working_copy.path}" cmd = "rake #{name}" cmd << " --trace" if Rake.application..trace # This is a work-around for funky handling of processes on # Windows. If not done, rake will always fail with the following # message: # > rake aborted! # > undefined method `exitstatus' for nil:NilClass cmd << " 2>&1" if RUBY_PLATFORM.match(/mswin/) sh cmd FileUtils.cd(cur_dir) end end if Chrysalis::Manifest.instance[:main].task?(name) puts "" puts "Invoking #{name}" Rake.application[name].invoke end end end @@tasks << name end end |