Skip to content

Instantly share code, notes, and snippets.

@zentrope
Created August 21, 2010 23:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zentrope/542991 to your computer and use it in GitHub Desktop.
Save zentrope/542991 to your computer and use it in GitHub Desktop.
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
@zentrope
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment