Created
August 21, 2010 23:02
-
-
Save zentrope/542991 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
base_dir = Dir.pwd | |
build_dir = "#{base_dir}/build" | |
src_dir = "#{base_dir}/src" | |
lib_dir = "#{base_dir}/lib" | |
def classpath(location) | |
places = File.join(location, "*.jar") | |
return Dir.glob(places).join(":") | |
end | |
task :prepare do | |
sh("mkdir -p #{build_dir}") | |
end | |
task :compile => [:prepare] do | |
libs = classpath(lib_dir) | |
cmd = "scalac -cp #{libs} -make:changed -d #{build_dir} #{src_dir}/*" | |
sh(cmd) | |
end | |
task :clean do | |
sh("rm -rf #{build_dir}") | |
end | |
task :run => [:compile] do | |
libs = classpath(lib_dir) + ":#{build_dir}" | |
cmd = "scala -cp #{libs} com.zentrope.Kernel" | |
sh cmd do | ok, res | | |
# Ignore what happens | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I don't know anything about Rake. Here's what I came up with by googling around for sample code. I use this to build my Scala app. The one problem I had is that the "classpath" function couldn't "see" the variables declared at the top. This is probably because my knowledge of Ruby is pretty thin.