I ran spec. spec complain about tools_jar variable is nil.

--- error message ---
can't convert nil into String

/Users/eungju/src/buildr/lib/buildr/java/compilers.rb:63:in `exist?'

61 tools_jar = [File.expand_path('lib/tools.jar', ENV['JAVA_HOME']), File.expand_path('../lib/tools.jar', ENV['JAVA_HOME'])].
62          find { |path| File.exist?(path) }
63        dependencies << tools_jar if File.exist?(tools_jar)
64 cmd_args << '-classpath' << dependencies.join(File::PATH_SEPARATOR) unless dependencies.empty? 65 source_paths = sources.select { |source| File.directory? (source) }
66# gem install syntax to get syntax highlighting

I tries to find tools.jar on all of my install JDKs, but I can't.
I found Mac OS X JDK doesn't provides tools.jar. See http://developer.apple.com/documentation/Java/Conceptual/Java14Development/02-JavaDevTools/JavaDevTools.html#/ /apple_ref/doc/uid/TP40001884-SW1

Javac.compile should handle this case.

Index: lib/buildr/java/compilers.rb
===================================================================
--- lib/buildr/java/compilers.rb        (revision 694959)
+++ lib/buildr/java/compilers.rb        (working copy)
@@ -60,7 +60,7 @@
         # but maybe the JRE.
tools_jar = [File.expand_path('lib/tools.jar', ENV['JAVA_HOME']), File.expand_path('../lib/tools.jar', ENV['JAVA_HOME'])].
           find { |path| File.exist?(path) }
-        dependencies << tools_jar if File.exist?(tools_jar)
+ dependencies << tools_jar if tools_jar && File.exist? (tools_jar) cmd_args << '-classpath' << dependencies.join(File::PATH_SEPARATOR) unless dependencies.empty? source_paths = sources.select { |source| File.directory? (source) } cmd_args << '-sourcepath' << source_paths.join(File::PATH_SEPARATOR) unless source_paths.empty?

Reply via email to