Class: JavaRequirement Private

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

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

A requirement on Java.

Defined Under Namespace

Classes: CaskSuggestion

Constant Summary

Constants included from Dependable

Dependable::RESERVED_TAGS

Instance Attribute Summary collapse

Attributes inherited from Requirement

#cask, #download, #name, #tags

Instance Method Summary collapse

Methods inherited from Requirement

#==, env, #env, #env_proc, expand, #fatal?, #hash, #mktemp, #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, #prune_from_option?, #prune_if_build_and_not_dependent?, #recommended?, #required?, #test?

Constructor Details

#initialize(tags = []) ⇒ JavaRequirement

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of JavaRequirement.


33
34
35
36
37
# File 'Library/Homebrew/requirements/java_requirement.rb', line 33

def initialize(tags = [])
  @version = tags.shift if tags.first&.match?(/^\d/)
  super(tags)
  @cask = suggestion.token
end

Instance Attribute Details

#java_homeObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


11
12
13
# File 'Library/Homebrew/requirements/java_requirement.rb', line 11

def java_home
  @java_home
end

#versionObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


11
12
13
# File 'Library/Homebrew/requirements/java_requirement.rb', line 11

def version
  @version
end

Instance Method Details

#display_sObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


50
51
52
53
54
55
56
57
58
59
60
61
# File 'Library/Homebrew/requirements/java_requirement.rb', line 50

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

#inspectObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


46
47
48
# File 'Library/Homebrew/requirements/java_requirement.rb', line 46

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

#messageObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


39
40
41
42
43
44
# File 'Library/Homebrew/requirements/java_requirement.rb', line 39

def message
  version_string = " #{@version}" if @version
  s = "Java#{version_string} is required to install this formula.\n"
  s += suggestion
  s
end

#suggestionObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

A strict Java 8 requirement (1.8) should prompt the user to install an OpenJDK 1.8 distribution. 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.).


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

def suggestion
  if fits_latest?
    JAVA_SUGGESTION_MAP.fetch(JAVA_SUGGESTION_MAP.keys.max)
  else
    JAVA_SUGGESTION_MAP.fetch("1.8")
  end
end