Changeset 6104
- Timestamp:
- 11/23/06 18:55:22
- Files:
-
- trunk (modified) (1 prop)
- trunk/README (modified) (7 diffs)
- trunk/Rakefile (modified) (1 diff)
- trunk/lib/jerbil/java_helper.rb (modified) (1 diff)
- trunk/lib/jerbil/javac_task.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk
- Property svn:ignore changed from pkg html to pkg html rdoc
trunk/README
r6053 r6104 1 = Jerbil -- Java build system based on Rake[http://rake.rubyforge.org] and R JB1 = Jerbil -- Java build system based on Rake[http://rake.rubyforge.org] and Rjb 2 2 3 3 "If I knew then what I know now, I would have tried using a real … … 11 11 -- James Duncan Davidson, creator of Apache Ant 12 12 13 This package contains several TaskLibs for Rake which can be13 This package contains several TaskLibs for Rake[http://rake.rubyforge.org] which can be 14 14 used to build Java projects. 15 15 16 Jerbil uses R JB[http://raa.ruby-lang.org/project/rjb/]17 (Ruby-Java-Bridge) to load a Java virtual machine into Rake.16 Jerbil uses Rjb[http://rjb.rubyforge.org/] 17 (Ruby-Java-Bridge) to load a Java virtual machine into the Ruby process running Rake. 18 18 19 The jvmis then used to compile Java source files, create javadocs etc.19 The JVM is then used to compile Java source files, create javadocs etc. 20 20 It is not a complete replacement for ant (yet), but has several advantages such as 21 extremly compact build files and easy scriptability. 21 extremly compact build files and easy scriptability. 22 22 23 23 The main focus at the moment are small to medium-sized projects using … … 26 26 == Requirements 27 27 28 Jerbil requires rubygems[http://rubygems.org], Rake, RJB and JDK 1.5. 28 Jerbil requires rubygems[http://rubygems.org], Rake, Rjb, builder[http://builder.rubyforge.org/] 29 and JDK 1.5. 29 30 30 31 == Installation … … 34 35 % apt-get install rubygems 35 36 36 Rake and rjbare best installed using gem:37 Rake, Rjb and builder are best installed using gem: 37 38 38 39 % gem install rake 39 40 % gem install rjb 41 % gem install builder 40 42 41 The installation of rjb requires that the JDK is installed and JAVA_HOME set up43 The installation of Rjb requires that the JDK is installed and JAVA_HOME set up 42 44 accordingly. Finally jerbil needs to be installed: 43 45 … … 47 49 jar files, for example Jerbil::TestNG::TestNGTask. 48 50 49 The source code is available via subversion: http://svn.trampolinesystems.com/jerbil/ 51 The source code is available via subversion: http://svn.trampolinesystems.com/jerbil/trunk 50 52 53 == Usage 54 55 A minimal Rakefile to compile Java files looks like this: 56 57 require 'jerbil' 58 59 CLASSPATH = FileList[ "./lib/*.jar" ] 60 BUILD_DIR = "build" 61 FILES = JavaFileList.new("src", BUILD_DIR) 62 63 load_jvm(CLASSPATH, BUILD_DIR) 64 65 Jerbil::JavacTask.new(:compile, FILES) 66 67 The JVM gets loaded once via the +load_jvm+ method. This initialization step is 68 required, otherwise the task will fail. <tt>Jerbil::JavacTask.new(:compile, FILES)</tt> 69 defines a new task (<tt>:compile</tt>) which will compile all Java files found in directory 70 +src+ to +build+. 71 51 72 == Example 52 73 53 See the example/[http://svn.trampolinesystems.com/jerbil/trunk/example] subdirectory in the repository. 74 See the example/[http://svn.trampolinesystems.com/jerbil/trunk/example] subdirectory 75 in the repository. 54 76 55 77 % svn co http://svn.trampolinesystems.com/jerbil/trunk/example … … 57 79 == Advantages over Ant 58 80 59 Well, it's based on Ruby :) Additionally, RJB allows Ruby code to implement arbitary 60 Java interfaces which you can then pass into compiled Java code. 61 See Jerbil::TestNG::TestListener for an example. 81 See Martin Fowler's article[http://www.martinfowler.com/articles/rake.html] for a detailed 82 discussion on Rake vs. Ant. Besides the more compact build scripts you also get ability to 83 implement arbitrary Java interfaces in Ruby (see Jerbil::TestNG::TestListener for an example). 84 Another possibility is build script metaprogramming, i.e. creating your tasks programmatically: 85 86 MODULES = [ "common", "core", "server" ] 87 MODULES.each_with_index do |m,i| 88 Jerbil::JavacTask.new("compile_#{m}") do |jct| 89 jct.java_files = JavaFileList.new(File.join(m,SOURCE_DIR), JAVA_BUILD_DIR) 90 MODULES[0..i-1].each {|prev| jct.depends_on "compile_#{prev}" } if i>0 91 end 92 end 93 94 This snippet creates several build targets (:compile_common, :compile_core, :compile_server) 95 including correct dependencies. 62 96 63 97 == Related projects 64 98 65 * Raven[http://raven.rubyforge.org/]: similar to jerbil in scope, but different approach (invokes99 * Raven[http://raven.rubyforge.org/]: similar to Jerbil in scope, but different approach (invokes 66 100 javac directly, no Java-Ruby integration). 67 101 … … 72 106 == Contact 73 107 74 Questions? Feedback?75 108 mailto:jan@trampolinesystems.com 76 109 trunk/Rakefile
r6056 r6104 63 63 rdoc.options << '--line-numbers' << '--inline-source' << '--main' << 'README' 64 64 rdoc.rdoc_files.include("README", "CHANGES", "TODO", "LICENSE", "lib/**/*.rb") 65 rdoc.rdoc_dir = 'rdoc' 65 66 end 66 67 trunk/lib/jerbil/java_helper.rb
r6103 r6104 410 410 end 411 411 412 # make some stuff available to the toplevel 413 412 # make JavaFileList available to toplevel 414 413 JavaFileList = Jerbil::JavaFileList 415 414 415 # make load_jvm available to toplevel 416 416 def load_jvm(args, build_dir, options={}) 417 417 Jerbil::JavaHelper.load_jvm(args, build_dir, options) trunk/lib/jerbil/javac_task.rb
r6060 r6104 24 24 create_alias_for :g, :debug 25 25 26 def initialize(name )26 def initialize(name, files = nil) 27 27 @name = name 28 28 @verbose = false 29 @java_files = files 29 30 30 31 yield self if block_given? 32 33 raise "need java_files" if java_files.nil? 34 31 35 depends_on java_files.dstdir 36 #CLEAN.include(java_files.dstdir) if CLEAN 37 32 38 define 33 39 end
