Code review cleanups

This commit is contained in:
Bob W. Hogg 2017-02-15 21:47:08 -08:00
parent 5a214de68d
commit c49b97dd9c
3 changed files with 6 additions and 10 deletions

View File

@ -4,12 +4,9 @@ class JavaRequirement < Requirement
default_formula "jdk"
env do
next unless @java_home
env_java_common
if (Pathname.new(@java_home)/"include").exist? # Oracle JVM
env_oracle_jdk
end
end
private

View File

@ -3,12 +3,7 @@ class JavaRequirement
env do
env_java_common
java_home = Pathname.new(@java_home)
if (java_home/"include").exist? # Oracle JVM
env_oracle_jdk
else # Apple JVM
env_apple
end
env_oracle_jdk || env_apple
end
private

View File

@ -83,15 +83,19 @@ class JavaRequirement < Requirement
end
def env_java_common
return unless @java_home
java_home = Pathname.new(@java_home)
ENV["JAVA_HOME"] = java_home
ENV.prepend_path "PATH", java_home/"bin"
end
def env_oracle_jdk
return unless @java_home
java_home = Pathname.new(@java_home)
return unless (java_home/"include").exist?
ENV.append_to_cflags "-I#{java_home}/include"
ENV.append_to_cflags "-I#{java_home}/include/#{oracle_java_os}"
true
end
def oracle_java_os