From a4bada575ae7957feb0de1ac4ea6bdc403e44da3 Mon Sep 17 00:00:00 2001 From: Mike McQuaid <mike@mikemcquaid.com> Date: Wed, 18 Apr 2018 09:55:44 +0100 Subject: [PATCH] requirements: define cask on base class. The `cask` attribute doesn't make as much sense on Linux but can be ignored there. The advantage of this change is that (like #4086) it allows figuring out the relevant cask for a formulae requirement on a Linux machine. --- .../os/mac/requirements/java_requirement.rb | 19 ------------------- .../mac/requirements/osxfuse_requirement.rb | 1 - .../os/mac/requirements/x11_requirement.rb | 1 - .../Homebrew/requirements/java_requirement.rb | 19 +++++++++++++++++++ .../requirements/osxfuse_requirement.rb | 1 + .../Homebrew/requirements/x11_requirement.rb | 1 + 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Library/Homebrew/extend/os/mac/requirements/java_requirement.rb b/Library/Homebrew/extend/os/mac/requirements/java_requirement.rb index 6f0608fe7a..b561d3c7af 100644 --- a/Library/Homebrew/extend/os/mac/requirements/java_requirement.rb +++ b/Library/Homebrew/extend/os/mac/requirements/java_requirement.rb @@ -4,29 +4,10 @@ class JavaRequirement < Requirement env_oracle_jdk || env_apple end - # A strict Java 8 requirement (1.8) should prompt the user to install - # the legacy java8 cask because versions newer than Java 8 are not - # completely backwards compatible, and contain breaking changes such as - # strong encapsulation of JDK-internal APIs and a modified version scheme - # (*.0 not 1.*). - 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 undef possible_javas, oracle_java_os - JAVA_CASK_MAP = { - "1.8" => "caskroom/versions/java8", - "10.0" => "java", - }.freeze - def possible_javas javas = [] javas << Pathname.new(ENV["JAVA_HOME"])/"bin/java" if ENV["JAVA_HOME"] diff --git a/Library/Homebrew/extend/os/mac/requirements/osxfuse_requirement.rb b/Library/Homebrew/extend/os/mac/requirements/osxfuse_requirement.rb index 3f10a951ac..89c2b8786b 100644 --- a/Library/Homebrew/extend/os/mac/requirements/osxfuse_requirement.rb +++ b/Library/Homebrew/extend/os/mac/requirements/osxfuse_requirement.rb @@ -1,7 +1,6 @@ require "requirement" class OsxfuseRequirement < Requirement - cask "osxfuse" download "https://osxfuse.github.io/" satisfy(build_env: false) { self.class.binary_osxfuse_installed? } diff --git a/Library/Homebrew/extend/os/mac/requirements/x11_requirement.rb b/Library/Homebrew/extend/os/mac/requirements/x11_requirement.rb index 6b1c5b13b4..7240a89727 100644 --- a/Library/Homebrew/extend/os/mac/requirements/x11_requirement.rb +++ b/Library/Homebrew/extend/os/mac/requirements/x11_requirement.rb @@ -1,7 +1,6 @@ require "requirement" class X11Requirement < Requirement - cask "xquartz" download "https://xquartz.macosforge.org" satisfy build_env: false do diff --git a/Library/Homebrew/requirements/java_requirement.rb b/Library/Homebrew/requirements/java_requirement.rb index 213203ff39..27348fa8cc 100644 --- a/Library/Homebrew/requirements/java_requirement.rb +++ b/Library/Homebrew/requirements/java_requirement.rb @@ -4,6 +4,20 @@ class JavaRequirement < Requirement fatal true download "https://www.oracle.com/technetwork/java/javase/downloads/index.html" + # A strict Java 8 requirement (1.8) should prompt the user to install + # the legacy java8 cask because versions newer than Java 8 are not + # completely backwards compatible, and contain breaking changes such as + # strong encapsulation of JDK-internal APIs and a modified version scheme + # (*.0 not 1.*). + 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 + satisfy build_env: false do setup_java next false unless @java @@ -42,6 +56,11 @@ class JavaRequirement < Requirement private + JAVA_CASK_MAP = { + "1.8" => "caskroom/versions/java8", + "10.0" => "java", + }.freeze + def version_without_plus if exact_version? @version diff --git a/Library/Homebrew/requirements/osxfuse_requirement.rb b/Library/Homebrew/requirements/osxfuse_requirement.rb index 9a07209d43..15da16c59c 100644 --- a/Library/Homebrew/requirements/osxfuse_requirement.rb +++ b/Library/Homebrew/requirements/osxfuse_requirement.rb @@ -1,6 +1,7 @@ require "requirement" class OsxfuseRequirement < Requirement + cask "osxfuse" fatal true end diff --git a/Library/Homebrew/requirements/x11_requirement.rb b/Library/Homebrew/requirements/x11_requirement.rb index 65ce6396fb..fc390b11cb 100644 --- a/Library/Homebrew/requirements/x11_requirement.rb +++ b/Library/Homebrew/requirements/x11_requirement.rb @@ -5,6 +5,7 @@ class X11Requirement < Requirement fatal true + cask "xquartz" env { ENV.x11 } def initialize(name = "x11", tags = []) -- GitLab