Changeset 6131
- Timestamp:
- 11/27/06 15:07:57
- Files:
-
- trunk/lib/jerbil/java_helper.rb (modified) (4 diffs)
- trunk/test/test_java_helper.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/jerbil/java_helper.rb
r6104 r6131 74 74 # Loads the java virtual machine. This method should only be invoked once, typically 75 75 # before task definitions in a Rakefile. If the environment variable +JAVA_OPTS+ is 76 # set, it will be treated as extra parameter for the initial VM load.76 # set, it will be treated as extra parameter for the initial VM load. 77 77 # 78 78 # +classpath+:: a Rake::FileList containing the initial classpath. 79 # +build_dir+:: an optional directory (or list of directories) which will be used to resolve classes at runtime.80 # Available options:81 # +:java_home+:: JDK path (defaults to ENV['JAVA_HOME']82 # +:java_opts+:: additional JVM arguments (defaults to ENV['JAVA_OPTS']83 # +:loggingprops+:: the location of a java.util.logging configuration file.84 # +:enableassert+:: wheter to enable assertions (default: enabled)79 # +build_dir+:: an optional directory (or list of directories) which will be used to resolve classes at runtime. 80 # Available options: 81 # +:java_home+:: JDK path (defaults to ENV['JAVA_HOME'] 82 # +:java_opts+:: additional JVM arguments (defaults to ENV['JAVA_OPTS'] 83 # +:loggingprops+:: the location of a java.util.logging configuration file. 84 # +:enableassert+:: wheter to enable assertions (default: enabled) 85 85 def JavaHelper.load_jvm(classpath, build_dir = nil, options = {} ) 86 86 87 defaultopts = { :enableassert => true }88 options = defaultopts.merge(options.dup)87 defaultopts = { :enableassert => true } 88 options = defaultopts.merge(options.dup) 89 89 90 90 #need verbose java exceptions … … 92 92 93 93 #include tools.jar from JDK (needed for javac etc.) 94 java_home = ENV['JAVA_HOME'] || options[:java_home] 94 guess_java_home 95 96 java_home = options[:java_home] || ENV['JAVA_HOME'] 97 98 puts "using JDK in #{java_home}" if Rake.application.options.trace 99 95 100 classpath.include(File.join(java_home, "lib", "tools.jar")) if java_home 96 #include build jars and custom classloader 97 classpath.include(File.join(File.dirname(__FILE__), "../../buildsupport/*.jar")) 101 #include custom classloader 98 102 classpath.include(File.join(File.dirname(__FILE__), "../../classloader")) if build_dir 99 103 100 101 104 jvmargs = [] 102 jvmargs << "-ea" if options[:enableassert]105 jvmargs << "-ea" if options[:enableassert] 103 106 jvmargs << "-Djava.util.logging.config.file=#{options[:loggingprops].to_s}" if options[:loggingprops] 104 107 … … 126 129 end 127 130 128 java_opts = ENV['JAVA_OPTS'] || options[:java_opts]129 jvmargs.unshift(java_opts) if java_opts130 131 puts jvmargs if ENV['JERBIL_DEBUG']132 133 begin131 java_opts = ENV['JAVA_OPTS'] || options[:java_opts] 132 jvmargs.unshift(java_opts) if java_opts 133 134 puts jvmargs if ENV['JERBIL_DEBUG'] 135 136 begin 134 137 Rjb::load(classpath.to_cp, jvmargs) 135 rescue 138 rescue 136 139 $stderr << "could not load java vm: make sure JAVA_HOME is set correctly!\n" 137 140 raise … … 140 143 #TODO: test javac main and raise if not found 141 144 end 142 end 145 146 # Tries to guess the JDK path if JAVA_HOME is not set (Windows only). 147 def JavaHelper.guess_java_home 148 if ENV['JAVA_HOME'].nil? && IS_WINDOWS 149 begin 150 require 'win32/registry' 151 Win32::Registry::HKEY_LOCAL_MACHINE.open('SOFTWARE\JavaSoft\Java Development Kit\1.5') do |reg| 152 ENV['JAVA_HOME'] = reg['JavaHome'] 153 end 154 rescue 155 end 156 end 157 end 158 159 end # module JavaHelper 143 160 144 161 ###################################################################### trunk/test/test_java_helper.rb
r6060 r6131 20 20 21 21 def test_to_classes 22 JavaHelper.guess_java_home 22 23 flist = JavaFileList.new("src","dst") 23 24 flist.add("java/lang/String.java")
