diff options
| author | JCount | 2017-10-26 11:26:00 -0400 |
|---|---|---|
| committer | GitHub | 2017-10-26 11:26:00 -0400 |
| commit | badbb00b0867846afa6d55275bca4edff959e908 (patch) | |
| tree | a847254845295d9707358c29255611dd51676188 /Library | |
| parent | 40b212322ce4b248fce05a376c041499e78570d8 (diff) | |
| parent | 224864b1490700e995a0133d6fdd4edefb645c0a (diff) | |
| download | brew-badbb00b0867846afa6d55275bca4edff959e908.tar.bz2 | |
Merge pull request #3352 from JCount/legacy-java-cask-requirement-support
java_requirement: support prompting users to install legacy Java casks
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/extend/os/mac/requirements/java_requirement.rb | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/Library/Homebrew/extend/os/mac/requirements/java_requirement.rb b/Library/Homebrew/extend/os/mac/requirements/java_requirement.rb index 2f132d740..2a48f02bd 100644 --- a/Library/Homebrew/extend/os/mac/requirements/java_requirement.rb +++ b/Library/Homebrew/extend/os/mac/requirements/java_requirement.rb @@ -1,13 +1,30 @@ class JavaRequirement < Requirement - cask "java" - env do env_java_common env_oracle_jdk || env_apple end + # A strict Java 8 requirement (1.8) should prompt the user to install + # the legacy java8 cask because the current version, Java 9, is not + # completely backwards compatible, and contains breaking changes such as + # strong encapsulation of JDK-internal APIs and a modified version scheme + # (9.0 not 1.9). + def cask + if @version.nil? || @version.to_s.end_with?("+") || + @version.to_f >= JAVA_CASK_MAP.keys.max.to_f + JAVA_CASK_MAP.fetch(JAVA_CASK_MAP.keys.max) + else + JAVA_CASK_MAP.fetch("1.8") + end + end + private + JAVA_CASK_MAP = { + "1.8" => "caskroom/versions/java8", + "9.0" => "java", + }.freeze + def possible_javas javas = [] javas << Pathname.new(ENV["JAVA_HOME"])/"bin/java" if ENV["JAVA_HOME"] |
