Class: JavaRequirement

Inherits:
Requirement show all
Defined in:
Library/Homebrew/requirements/java_requirement.rb,
Library/Homebrew/extend/os/mac/requirements/java_requirement.rb,
Library/Homebrew/extend/os/linux/requirements/java_requirement.rb

Constant Summary

Constants included from Dependable

Dependable::RESERVED_TAGS

Instance Attribute Summary

Attributes inherited from Requirement

#download, #name, #tags

Instance Method Summary collapse

Methods inherited from Requirement

#==, default_formula, #env, env, #env_proc, expand, #fatal?, #hash, #modify_build_environment, #option_names, prune, prune?, #satisfied?, #satisfied_result_parent, satisfy

Methods included from BuildEnvironment::DSL

#env

Methods included from Dependable

#build?, #option_tags, #optional?, #options, #recommended?, #required?, #run?

Constructor Details

#initialize(tags = []) ⇒ JavaRequirement

Returns a new instance of JavaRequirement



13
14
15
16
# File 'Library/Homebrew/requirements/java_requirement.rb', line 13

def initialize(tags = [])
  @version = tags.shift if /(\d+\.)+\d/ =~ tags.first
  super
end

Instance Method Details

#caskObject

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).



12
13
14
15
16
17
18
19
# File 'Library/Homebrew/extend/os/mac/requirements/java_requirement.rb', line 12

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

#display_sObject



30
31
32
33
34
35
36
37
38
39
40
41
# File 'Library/Homebrew/requirements/java_requirement.rb', line 30

def display_s
  if @version
    if exact_version?
      op = "="
    else
      op = ">="
    end
    "#{name} #{op} #{version_without_plus}"
  else
    name
  end
end

#inspectObject



26
27
28
# File 'Library/Homebrew/requirements/java_requirement.rb', line 26

def inspect
  "#<#{self.class.name}: #{name.inspect} #{tags.inspect} version=#{@version.inspect}>"
end

#messageObject



18
19
20
21
22
23
24
# File 'Library/Homebrew/requirements/java_requirement.rb', line 18

def message
  version_string = " #{@version}" if @version

  s = "Java#{version_string} is required to install this formula.\n"
  s += super
  s
end