brew/Library/Homebrew/extend/os/mac/requirements/java_requirement.rb
Bob W. Hogg e0d5afc237 java_requirement: Make macOS overrides extend Requirement
This doesn't actually seem to make that much difference,
but it is at least consistent with the main class body and with
the Linux overrides.
2017-02-20 19:19:26 -08:00

36 lines
793 B
Ruby

class JavaRequirement < Requirement
cask "java"
env do
env_java_common
env_oracle_jdk || env_apple
end
private
def possible_javas
javas = []
javas << Pathname.new(ENV["JAVA_HOME"])/"bin/java" if ENV["JAVA_HOME"]
javas << java_home_cmd
javas << which("java")
javas
end
def java_home_cmd
return nil unless File.executable?("/usr/libexec/java_home")
args = %w[--failfast]
args << "--version" << @version.to_s if @version
java_home = Utils.popen_read("/usr/libexec/java_home", *args).chomp
return nil unless $?.success?
Pathname.new(java_home)/"bin/java"
end
def env_apple
ENV.append_to_cflags "-I/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers/"
end
def oracle_java_os
:darwin
end
end