Inertia

rake

rake is Makefile for ruby world. I am not big fan of Ruby but I like Rake as a task execuion library.

task defintion & dependency

1
2
3
4
5
6
7
task :A do
sh "echo A task executed"
end

task B: [:A ] do
sh "echo A task executed"
end

find directory where rake is invoked.

sometimes, maven or gradle build command should be executed at project root directory. but current directory is changed by Rake where the Rakefile is located. so build command would fail by that reason. in this case we can get the origial directory by using the following Ruby APIs.

1
2
3
4
5
dir = Rake.application.original_dir
Dir.chdir(dir) do
sh "mvn"
sh "gradle"
end