require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'rubygems'
require 'antwrap'
require 'java'
web_dir = "../web"
common_lib_dir = "../lib"


@ant = Antwrap::AntProject.new(:ant_home=>'/usr/share/ant')
@ant.mkdir(:dir => "classes")
@ant.path(:id => "common.class.path"){
@ant.fileset(:dir => "#{common_lib_dir}"){
@ant.include(:name => "**/*.jar")
}
}

desc "clean the classes directory"
task :clean do
@ant.delete(:dir => "classes")
end

desc "generate war file"
task :war =>[:compile] do
@ant.war(:update => false, :destfile=>"ei.war", :webxml=>"../web/WEB-INF/web.xml"){
@ant.fileset(:dir => web_dir)
}
end

task :default => [:compile]

desc "compile java classes"
task :compile do
puts "compiling java classes to [classes]..."
@ant.javac(:srcdir => "../src", :destdir => "classes", :deprecation=>true, :debug=>true, :fork=>true){
@ant.classpath(:refid => "common.class.path")
@ant.compilerarg(:value =>"-Xlint")
}
end

end