mirror of
https://github.com/gosticks/brew.git
synced 2026-12-06 12:31:48 +00:00
DependencyCollector: Add java_dep_if_needed [Linux]
Use the openjdk formula if it's installed. Use the host's Java if it's sufficient. Otherwise install the openjdk formula.
This commit is contained in:
@@ -79,6 +79,10 @@ class DependencyCollector
|
||||
Dependency.new("bzip2", tags) unless which("bzip2")
|
||||
end
|
||||
|
||||
def java_dep_if_needed(tags)
|
||||
JavaRequirement.new(tags)
|
||||
end
|
||||
|
||||
def ld64_dep_if_needed(*); end
|
||||
|
||||
def self.tar_needs_xz_dependency?
|
||||
@@ -118,7 +122,7 @@ class DependencyCollector
|
||||
case spec
|
||||
when :arch then ArchRequirement.new(tags)
|
||||
when :codesign then CodesignRequirement.new(tags)
|
||||
when :java then JavaRequirement.new(tags)
|
||||
when :java then java_dep_if_needed(tags)
|
||||
when :linux then LinuxRequirement.new(tags)
|
||||
when :macos then MacOSRequirement.new(tags)
|
||||
when :maximum_macos then MaximumMacOSRequirement.new(tags)
|
||||
|
||||
@@ -1 +1,5 @@
|
||||
require "extend/os/mac/dependency_collector" if OS.mac?
|
||||
if OS.mac?
|
||||
require "extend/os/mac/dependency_collector"
|
||||
elsif OS.linux?
|
||||
require "extend/os/linux/dependency_collector"
|
||||
end
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
class DependencyCollector
|
||||
def java_dep_if_needed(tags)
|
||||
req = JavaRequirement.new(tags)
|
||||
begin
|
||||
dep = Dependency.new("openjdk", tags)
|
||||
return dep if dep.installed?
|
||||
return req if req.satisfied?
|
||||
dep
|
||||
rescue FormulaUnavailableError
|
||||
req
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -86,7 +86,7 @@ class JavaRequirement < Requirement
|
||||
javas = []
|
||||
javas << Pathname.new(ENV["JAVA_HOME"])/"bin/java" if ENV["JAVA_HOME"]
|
||||
jdk = begin
|
||||
Formula["jdk"]
|
||||
Formula["openjdk"]
|
||||
rescue FormulaUnavailableError
|
||||
nil
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user