$:.unshift File.join( File.dirname(__FILE__), "..", "lib" ) require 'rake' require 'rake/clean' require 'jerbil' require 'buildconfig' CLEAN.include(BUILD_DIR, DIST_DIR,TESTOUTPUTDIR) load_jvm(CLASSPATH, JAVA_BUILD_DIR) task :default => :compile desc "compile all java files" Jerbil::JavacTask.new(:compile) do |t| t.java_files = JAVA_FILES t.options :nowarn, :debug t.source = "1.5" t.target = "1.5" end desc "compile all java files with separate resources" Jerbil::JavacTask.new(:compile_with_separate_resources) do |t| t.java_files = JAVA_FILES_WITH_RESOURCES t.options :nowarn, :debug t.source = "1.5" t.target = "1.5" end desc "compile all tests" Jerbil::JavacTask.new(:test_compile) do |t| t.java_files = JAVA_TEST_FILES t.depends_on :compile end desc "run tests" Jerbil::TestNG::TestNGTask.new(:test) do |t| t.outputdir = TESTOUTPUTDIR t.tests = JAVA_TEST_FILES t.depends_on :test_compile end Jerbil::JavaDocTask.new do |t| t.sourcepath = SOURCE_DIR t.subpackages = "jerbil" t.dstdir = JAVADOC_DIR t.options :quiet t.depends_on :compile end Jerbil::JarTask.new do |t| t.dir = JAVA_BUILD_DIR t.filename = DISTJAR t.depends_on :clean, :compile end Jerbil::JavaTask.new(:run, "jerbil.example.Main") do |t| t.classpath = CLASSPATH t.parameters = [ "20", "50" ] t.depends_on :compile end Jerbil::JavaTask.new(:run_in_vm, "jerbil.example.Main") do |t| t.classpath = CLASSPATH t.parameters = [ "20", "50" ] t.depends_on :compile t.in_vm = true end Jerbil::JavaTask.new(:run_forked, "jerbil.example.Main") do |t| t.classpath = CLASSPATH t.parameters = [ "50", "-50" ] t.depends_on :compile t.fork = true end Jerbil::JavaTask.new(:run_forked_fail, "jerbil.example.Main") do |t| t.classpath = CLASSPATH t.parameters = [ "0", "20" ] t.depends_on :compile t.fork = true end Jerbil::JavaTask.new(:test_java_task, "jerbil.example.Main2") do |t| t.classpath = CLASSPATH t.sys_property "jerbil.foo", "baz" t.max_mem = 64 t.logging_conf = "foo.properties" t.fork = true t.depends_on :compile end file ANNOTATED_CLASSES => [ :find_annotations ] file ENTITIES_YML => [ :find_annotations ] desc "find annotations and write output to #{ANNOTATED_CLASSES}" Jerbil::AptTask.new(:find_annotations) do |t| t.java_files= JAVA_FILES t.nocompile = true t.depends_on :compile t.find_annotation 'jerbil.example.MyAnnotation' do |classes| File.open(ANNOTATED_CLASSES, 'w') { |f| f << classes.to_yaml } end t.annotated_classes_to_yaml('javax.persistence.Entity', ENTITIES_YML) end desc "create sql schema from annotations" Jerbil::Hibernate::ExportSchemaTask.new(:export_schema) do |t| t.schemafile = DB_SCHEMA t.entities_yml = ENTITIES_YML end desc "validate schema success" Jerbil::Hibernate::ExportSchemaTask.new(:validate_schema_success) do |t| t.schemafile = DB_SCHEMA t.entities_yml = ENTITIES_YML t.validate :all t.filter { |classname| classname =~ /^jerbil\.example\.JerbilEntity/ } # not used, just for testing t.inflections { |inflect| inflect.irregular( 'data' , 'data') } end desc "validate schema failure" Jerbil::Hibernate::ExportSchemaTask.new(:validate_schema_failure) do |t| t.schemafile = DB_SCHEMA t.entities_yml = ENTITIES_YML t.validate :all t.filter { |classname| classname =~ /^jerbil\.example\.EntityWithValidationErrors/ } end Jerbil::Hibernate::ExportSchemaTask.new(:export_schema_filtered) do |t| t.schemafile = DB_SCHEMA t.entities_yml = ENTITIES_YML t.filter { |classname| classname =~ /^merbil\./ } end Jerbil::DmgTask.new do |t| t.dmgfile = File.join(DIST_DIR, "test.dmg") t.appname = "test" t.mainclass = "jerbil.example.Main" t.classpath = FileList["./lib/*.jar" ] end