Changeset 6140
- Timestamp:
- 11/27/06 22:35:02
- Files:
-
- trunk/README (modified) (5 diffs)
- trunk/lib/jerbil/java_helper.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/README
r6138 r6140 31 31 == Installation 32 32 33 You need to have Ruby and rubygems installed. The Windows version of Ruby already ships with gem.34 On Debian systems (testing) you can install it using apt-get:33 You need to have Ruby and rubygems installed. The Windows version of Ruby already ships with rubygems 34 preinstalled. On Debian systems (testing) you can install it using apt-get: 35 35 36 36 % apt-get install rubygems … … 39 39 40 40 % gem install rake 41 % gem install builder 41 42 % gem install rjb 42 % gem install builder43 43 44 The installation of Rjb requires that the JDK is installed and JAVA_HOME set up 45 accordingly. Finally jerbil needs to be installed: 44 The installation of Rjb can be a bit tricky for non-Windows users because 45 JAVA_HOME needs to be set up correctly. Also, a C compiler is required in order to 46 build the JNI extension for Ruby. 47 48 Finally jerbil needs to be installed: 46 49 47 50 % gem install jerbil --source http://code.trampolinesystems.com … … 66 69 Jerbil::JavacTask.new(:compile, FILES) 67 70 68 The JVM gets loaded once via the +load_jvm+method. This initialization step is71 The JVM gets loaded once via the Jerbil::JavaHelper load_jvm method. This initialization step is 69 72 required, otherwise the task will fail. <tt>Jerbil::JavacTask.new(:compile, FILES)</tt> 70 73 defines a new task (<tt>:compile</tt>) which will compile all Java files found in directory 71 74 +src+ to +build+. 72 75 76 === Debugging 77 78 As all the code runs in a single JVM, debugging can only be enabled on a global level. 79 Just add the environment variable +JAVA_DEBUG+. 80 81 % JAVA_DEBUG='1' rake test 82 83 This will load the JVM in debug mode, listening on port 8000. To specify a different port, 84 use JAVA_DEBUG='port=33333'. Adding +suspend+ to the +JAVA_DEBUG+ environment will suspend execution 85 until the debugging client connects. 86 87 === Specifiying additional jvm options 88 89 % JAVA_OPTS = '-Xmx=256M' rake test 90 or 91 load_jvm(CLASSPATH, BUILD, :java_opts=>"-Xmx=256M") 92 73 93 == Example 74 94 … … 76 96 in the repository. 77 97 78 % svn c heckouthttp://svn.trampolinesystems.com/jerbil/trunk/example98 % svn co http://svn.trampolinesystems.com/jerbil/trunk/example 79 99 80 100 == Advantages over Ant … … 87 107 MODULES = [ "common", "core", "server" ] 88 108 MODULES.each_with_index do |m,i| 89 Jerbil::JavacTask.new("compile_#{m}") do |jct| 90 jct.java_files = JavaFileList.new(File.join(m,SOURCE_DIR), JAVA_BUILD_DIR) 91 MODULES[0..i-1].each {|prev| jct.depends_on "compile_#{prev}" } if i>0 109 Jerbil::JavacTask.new("compile_#{m}") do |t| 110 t.java_files = JavaFileList.new(File.join(m,SRC_DIR), DST_DIR) 111 MODULES[0..i-1].each { 112 |prev| t.depends_on "compile_#{prev}" 113 } if i>0 92 114 end 93 115 end 94 116 95 This snippet creates several build targets ( :compile_common, :compile_core, :compile_server)96 including correct dependencies.117 This snippet creates several build targets (+:compile_common+, +:compile_core+, 118 +:compile_server+) including correct dependency setup. 97 119 98 120 Lastly, all the tasks run in one single JVM, speeding up the build significantly. trunk/lib/jerbil/java_helper.rb
r6138 r6140 90 90 #need verbose java exceptions 91 91 $VERBOSE = true 92 92 93 guess_java_home 94 java_home = options[:java_home] || ENV['JAVA_HOME'] 95 96 puts "using JDK in #{java_home}" if Rake.application.options.trace 97 93 98 #include tools.jar from JDK (needed for javac etc.) 94 guess_java_home95 96 java_home = options[:java_home] || ENV['JAVA_HOME']97 98 puts "using JDK in #{java_home}" if Rake.application.options.trace99 100 99 classpath.include(File.join(java_home, "lib", "tools.jar")) if java_home 101 100 #include custom classloader … … 108 107 if ENV['JAVA_DEBUG'] 109 108 suspend = ENV['JAVA_DEBUG'].to_s.index('suspend') ? 'y' : 'n' 109 port = 8000 110 if ENV['JAVA_DEBUG'] =~ /port=([0-9]+)/ 111 port = $1 112 end 113 110 114 jvmargs += [ 111 115 "-Xdebug", 112 116 "-Xnoagent", 113 "-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=#{suspend}" ] 114 end 115 116 #java_home = ENV['JAVA_HOME'] 117 #ENV['LD_LIBRARY_PATH'] = "#{java_home}/jre/lib/i386:#{java_home}/jre/lib/i386/client" 118 119 #puts "lib:" + ENV['LD_LIBRARY_PATH'] 120 #jvmargs << "-Djava.library.path=#{ENV['JAVA_HOME']}/jre/lib/i386" 121 117 "-Xrunjdwp:transport=dt_socket,address=#{port},server=y,suspend=#{suspend}" ] 118 end 119 122 120 if build_dir 123 121 jerbil_debug = ENV['JERBIL_DEBUG'] ? 'true' : 'false'
