Disable Java requirement versions on Big Sur

It would be possible to work around this but I'm not convinced it's
worth it given https://github.com/Homebrew/homebrew-core/issues/63290

Fixes #9194
This commit is contained in:
Mike McQuaid 2020-11-19 14:03:57 +00:00
parent 181baaafb0
commit 35db40fe25
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70
4 changed files with 18 additions and 7 deletions

View File

@ -26,6 +26,13 @@ class JavaRequirement < Requirement
end
def java_home_cmd
# TODO: enable for all macOS versions and Linux on next minor release
# but --version is broken on Big Sur today.
if @version && MacOS.version >= :big_sur
odisabled "depends_on :java",
'"depends_on "openjdk@11", "depends_on "openjdk@8" or "depends_on "openjdk"'
end
return unless File.executable?("/usr/libexec/java_home")
args = %w[--failfast]

View File

@ -5,10 +5,12 @@ require "language/java"
describe Language::Java do
describe "::java_home" do
if !OS.mac? || MacOS.version < :big_sur
it "returns valid JAVA_HOME if version is specified", :needs_java do
java_home = described_class.java_home("1.6+")
expect(java_home/"bin/java").to be_an_executable
end
end
it "returns valid JAVA_HOME if version is not specified", :needs_java do
java_home = described_class.java_home

View File

@ -68,10 +68,12 @@ describe JavaRequirement do
describe "#satisfied?" do
subject(:requirement) { described_class.new(%w[1.8]) }
if !OS.mac? || MacOS.version < :big_sur
it "returns false if no `java` executable can be found" do
allow(File).to receive(:executable?).and_return(false)
expect(requirement).not_to be_satisfied
end
end
it "returns true if #preferred_java returns a path" do
allow(requirement).to receive(:preferred_java).and_return(Pathname.new("/usr/bin/java"))

View File

@ -110,7 +110,7 @@ RSpec.configure do |config|
config.before(:each, :needs_java) do
java_installed = if OS.mac?
Utils.popen_read("/usr/libexec/java_home", "--failfast", "--version", "1.0+")
Utils.popen_read("/usr/libexec/java_home", "--failfast")
$CHILD_STATUS.success?
else
which("java")