aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/system_config.rb
diff options
context:
space:
mode:
authorMaxim Belkin2018-02-22 14:20:23 +0000
committerMaxim Belkin2018-02-22 18:32:21 +0000
commit5536f49305fbb45261afcc1740a7a943a1c95f40 (patch)
tree88954cce873277c883159edbd9e8cc6471b08769 /Library/Homebrew/system_config.rb
parent14d54ed4b6b61c99abc4517d73d2b35079febdc7 (diff)
downloadbrew-5536f49305fbb45261afcc1740a7a943a1c95f40.tar.bz2
Cross-platform java detection
Diffstat (limited to 'Library/Homebrew/system_config.rb')
-rw-r--r--Library/Homebrew/system_config.rb12
1 files changed, 3 insertions, 9 deletions
diff --git a/Library/Homebrew/system_config.rb b/Library/Homebrew/system_config.rb
index 28eecf951..9a8d1d9d3 100644
--- a/Library/Homebrew/system_config.rb
+++ b/Library/Homebrew/system_config.rb
@@ -131,16 +131,10 @@ class SystemConfig
end
def describe_java
- # java_home doesn't exist on all macOSs; it might be missing on older versions.
- return "N/A" unless File.executable? "/usr/libexec/java_home"
-
- java_xml = Utils.popen_read("/usr/libexec/java_home", "--xml", "--failfast", err: :close)
+ return "N/A" unless which "java"
+ java_version = Utils.popen_read("java", "-version")
return "N/A" unless $CHILD_STATUS.success?
- javas = []
- REXML::XPath.each(REXML::Document.new(java_xml), "//key[text()='JVMVersion']/following-sibling::string") do |item|
- javas << item.text
- end
- javas.uniq.join(", ")
+ java_version[/java version "([0-9\._]+)"/, 1] || "N/A"
end
def describe_git