| 1 |
$:.unshift File.join( File.dirname(__FILE__), "..", "lib" ) |
|---|
| 2 |
|
|---|
| 3 |
require 'rake' |
|---|
| 4 |
require 'rake/clean' |
|---|
| 5 |
require 'jerbil' |
|---|
| 6 |
require 'buildconfig' |
|---|
| 7 |
|
|---|
| 8 |
CLEAN.include(BUILD_DIR, DIST_DIR,TESTOUTPUTDIR) |
|---|
| 9 |
|
|---|
| 10 |
load_jvm(CLASSPATH, JAVA_BUILD_DIR) |
|---|
| 11 |
|
|---|
| 12 |
task :default => :compile |
|---|
| 13 |
|
|---|
| 14 |
desc "compile all java files" |
|---|
| 15 |
Jerbil::JavacTask.new(:compile) do |t| |
|---|
| 16 |
t.java_files = JAVA_FILES |
|---|
| 17 |
t.options :nowarn, :debug |
|---|
| 18 |
t.source = "1.5" |
|---|
| 19 |
t.target = "1.5" |
|---|
| 20 |
end |
|---|
| 21 |
|
|---|
| 22 |
desc "compile all java files with separate resources" |
|---|
| 23 |
Jerbil::JavacTask.new(:compile_with_separate_resources) do |t| |
|---|
| 24 |
t.java_files = JAVA_FILES_WITH_RESOURCES |
|---|
| 25 |
t.options :nowarn, :debug |
|---|
| 26 |
t.source = "1.5" |
|---|
| 27 |
t.target = "1.5" |
|---|
| 28 |
end |
|---|
| 29 |
|
|---|
| 30 |
desc "compile all tests" |
|---|
| 31 |
Jerbil::JavacTask.new(:test_compile) do |t| |
|---|
| 32 |
t.java_files = JAVA_TEST_FILES |
|---|
| 33 |
t.depends_on :compile |
|---|
| 34 |
end |
|---|
| 35 |
|
|---|
| 36 |
desc "run tests" |
|---|
| 37 |
Jerbil::TestNG::TestNGTask.new(:test) do |t| |
|---|
| 38 |
t.outputdir = TESTOUTPUTDIR |
|---|
| 39 |
t.tests = JAVA_TEST_FILES |
|---|
| 40 |
t.depends_on :test_compile |
|---|
| 41 |
end |
|---|
| 42 |
|
|---|
| 43 |
Jerbil::JavaDocTask.new do |t| |
|---|
| 44 |
t.sourcepath = SOURCE_DIR |
|---|
| 45 |
t.subpackages = "jerbil" |
|---|
| 46 |
t.dstdir = JAVADOC_DIR |
|---|
| 47 |
t.options :quiet |
|---|
| 48 |
t.depends_on :compile |
|---|
| 49 |
end |
|---|
| 50 |
|
|---|
| 51 |
Jerbil::JarTask.new do |t| |
|---|
| 52 |
t.dir = JAVA_BUILD_DIR |
|---|
| 53 |
t.filename = DISTJAR |
|---|
| 54 |
t.depends_on :clean, :compile |
|---|
| 55 |
end |
|---|
| 56 |
|
|---|
| 57 |
Jerbil::JavaTask.new(:run, "jerbil.example.Main") do |t| |
|---|
| 58 |
t.classpath = CLASSPATH |
|---|
| 59 |
t.parameters = [ "20", "50" ] |
|---|
| 60 |
t.depends_on :compile |
|---|
| 61 |
end |
|---|
| 62 |
|
|---|
| 63 |
Jerbil::JavaTask.new(:run_in_vm, "jerbil.example.Main") do |t| |
|---|
| 64 |
t.classpath = CLASSPATH |
|---|
| 65 |
t.parameters = [ "20", "50" ] |
|---|
| 66 |
t.depends_on :compile |
|---|
| 67 |
t.in_vm = true |
|---|
| 68 |
end |
|---|
| 69 |
|
|---|
| 70 |
Jerbil::JavaTask.new(:run_forked, "jerbil.example.Main") do |t| |
|---|
| 71 |
t.classpath = CLASSPATH |
|---|
| 72 |
t.parameters = [ "50", "-50" ] |
|---|
| 73 |
t.depends_on :compile |
|---|
| 74 |
t.fork = true |
|---|
| 75 |
end |
|---|
| 76 |
|
|---|
| 77 |
Jerbil::JavaTask.new(:run_forked_fail, "jerbil.example.Main") do |t| |
|---|
| 78 |
t.classpath = CLASSPATH |
|---|
| 79 |
t.parameters = [ "0", "20" ] |
|---|
| 80 |
t.depends_on :compile |
|---|
| 81 |
t.fork = true |
|---|
| 82 |
end |
|---|
| 83 |
|
|---|
| 84 |
Jerbil::JavaTask.new(:test_java_task, "jerbil.example.Main2") do |t| |
|---|
| 85 |
t.classpath = CLASSPATH |
|---|
| 86 |
t.sys_property "jerbil.foo", "baz" |
|---|
| 87 |
t.max_mem = 64 |
|---|
| 88 |
t.logging_conf = "foo.properties" |
|---|
| 89 |
t.fork = true |
|---|
| 90 |
t.depends_on :compile |
|---|
| 91 |
end |
|---|
| 92 |
|
|---|
| 93 |
file ANNOTATED_CLASSES => [ :find_annotations ] |
|---|
| 94 |
file ENTITIES_YML => [ :find_annotations ] |
|---|
| 95 |
desc "find annotations and write output to #{ANNOTATED_CLASSES}" |
|---|
| 96 |
Jerbil::AptTask.new(:find_annotations) do |t| |
|---|
| 97 |
t.java_files= JAVA_FILES |
|---|
| 98 |
t.nocompile = true |
|---|
| 99 |
t.depends_on :compile |
|---|
| 100 |
t.find_annotation 'jerbil.example.MyAnnotation' do |classes| |
|---|
| 101 |
File.open(ANNOTATED_CLASSES, 'w') { |f| f << classes.to_yaml } |
|---|
| 102 |
end |
|---|
| 103 |
t.annotated_classes_to_yaml('javax.persistence.Entity', ENTITIES_YML) |
|---|
| 104 |
end |
|---|
| 105 |
|
|---|
| 106 |
|
|---|
| 107 |
desc "create sql schema from annotations" |
|---|
| 108 |
Jerbil::Hibernate::ExportSchemaTask.new(:export_schema) do |t| |
|---|
| 109 |
t.schemafile = DB_SCHEMA |
|---|
| 110 |
t.entities_yml = ENTITIES_YML |
|---|
| 111 |
end |
|---|
| 112 |
|
|---|
| 113 |
desc "validate schema success" |
|---|
| 114 |
Jerbil::Hibernate::ExportSchemaTask.new(:validate_schema_success) do |t| |
|---|
| 115 |
t.schemafile = DB_SCHEMA |
|---|
| 116 |
t.entities_yml = ENTITIES_YML |
|---|
| 117 |
t.validate :all |
|---|
| 118 |
t.filter { |classname| classname =~ /^jerbil\.example\.JerbilEntity/ } |
|---|
| 119 |
|
|---|
| 120 |
# not used, just for testing |
|---|
| 121 |
t.inflections { |inflect| inflect.irregular( 'data' , 'data') } |
|---|
| 122 |
end |
|---|
| 123 |
|
|---|
| 124 |
desc "validate schema failure" |
|---|
| 125 |
Jerbil::Hibernate::ExportSchemaTask.new(:validate_schema_failure) do |t| |
|---|
| 126 |
t.schemafile = DB_SCHEMA |
|---|
| 127 |
t.entities_yml = ENTITIES_YML |
|---|
| 128 |
t.validate :all |
|---|
| 129 |
t.filter { |classname| classname =~ /^jerbil\.example\.EntityWithValidationErrors/ } |
|---|
| 130 |
end |
|---|
| 131 |
|
|---|
| 132 |
Jerbil::Hibernate::ExportSchemaTask.new(:export_schema_filtered) do |t| |
|---|
| 133 |
t.schemafile = DB_SCHEMA |
|---|
| 134 |
t.entities_yml = ENTITIES_YML |
|---|
| 135 |
t.filter { |classname| classname =~ /^merbil\./ } |
|---|
| 136 |
end |
|---|
| 137 |
|
|---|
| 138 |
Jerbil::DmgTask.new do |t| |
|---|
| 139 |
t.dmgfile = File.join(DIST_DIR, "test.dmg") |
|---|
| 140 |
t.appname = "test" |
|---|
| 141 |
t.mainclass = "jerbil.example.Main" |
|---|
| 142 |
t.classpath = FileList["./lib/*.jar" ] |
|---|
| 143 |
end |
|---|