I don't really know how to put these together. What I do know is that my
previous experience with ant was that I found it awkward, so I'd rather
use rake. I'm not so sure about raven if only because I'm not convinced
that JRuby is viable and that if I run into a problem there may be no
solution, or that I won't be able to find it in a timely fashion.
I'm inclined to go with rake and ruby, but don't know how to get started
with rake. What would be the first step in creating a rake compile task
from Tasks.compile ?
thufir@arrakis:~/java$
thufir@arrakis:~/java$ cat tasks.rb
#/usr/bin/ruby
require 'fileutils'
module Tasks
JAVA = "/home/thufir/java/"
SRC = "src/"
BUILD = "build/"
COM = "com/"
WEB_TOMORROW = "web_tomorrow/"
PACKAGE = "package/"
def Tasks.clean
puts "\n\nclean...\n"
Dir.chdir("#{JAVA}")
puts "working directory:\t\t" + Dir.getwd + "\n\n"
FileUtils.rm_rf("#{BUILD}")
FileUtils.rm_rf("#{PACKAGE}")
Dir.mkdir("#{BUILD}")
Dir.mkdir(File.join(BUILD, COM))
Dir.mkdir(File.join(BUILD, COM, WEB_TOMORROW))
Dir.mkdir("#{PACKAGE}")
end
def Tasks.compile
puts "\n\ncompile...\n\n"
Dir.chdir(File.join(JAVA,SRC))
puts "working directory:\t\t" + Dir.getwd + "\n\n"
system("javac -cp . -d #{JAVA}#{BUILD} com/web_tomorrow/
CPTest2.java ")
end
def Tasks.create_manifest
puts "\n\ncreate_manifest...\n\n"
Dir.chdir(File.join(JAVA,BUILD))
File.open( 'manifest.txt', 'w' ) {
>f>
f.write("Main-Class:
com.web_tomorrow.CPTest2\n\n")
}
end
def Tasks.package
puts "\n\npackage...\n\n"
create_manifest
Dir.chdir("#{JAVA}")
puts "working directory:\t\t" + Dir.getwd + "\n\n"
# FileUtils.cp("/home/thufir/java/manifest.txt", "/home/
thufir/java/build/manifest.txt")
Dir.chdir("#{BUILD}")
puts "working directory:\t\t" + Dir.getwd + "\n\n"
system("jar -cfmv foo.jar manifest.txt com/web_tomorrow/
*.class")
FileUtils.mv("/home/thufir/java/build/foo.jar", "/home/
thufir/java/package/foo.jar")
end
def Tasks.examine_jar
puts "\n\nexamine_jar...\n\n"
Dir.chdir("#{BUILD}")
puts "working directory:\t\t" + Dir.getwd + "\n\n"
system("jar -tf foo.jar")
system("jar -xf foo.jar META-INF/MANIFEST.MF")
system("cat META-INF/MANIFEST.MF -n")
end
def Tasks.test
puts "\n\ntest...\n\n"
Dir.chdir("#{JAVA}")
Dir.chdir("#{PACKAGE}")
puts "working directory:\t\t" + Dir.getwd + "\n\n"
system("java -jar foo.jar")
end
end
thufir@arrakis:~/java$
thanks,
Thufir