Sha256: 74d759b5dcc98dbd272e66522175a5434b0c4157af09b615a4556a28235899c6

Contents?: true

Size: 1.38 KB

Versions: 99

Compression:

Stored size: 1.38 KB

Contents

#
# Copyright 2012 Mortar Data Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

require "mortar/local/installutil"

class Mortar::Local::Java
  include Mortar::Local::InstallUtil

  @command = nil

  def check_install
    jbin = File.join(ENV['JAVA_HOME']||'', "bin", "java")
    if ENV['JAVA_HOME'] and File.exists?(jbin)
      @command = jbin
      return true
    elsif File.exists?("/usr/libexec/java_home")
      # OSX has a nice little tool for finding this value, assuming
      # that it won't give us a bad value
      java_home = run_java_home
      if java_home != ""
        ENV['JAVA_HOME'] = java_home
        @command = File.join(ENV['JAVA_HOME'], "bin", "java")
        return true
      end
    end
    return false
  end

  # Runs the java_home command line tool which on osx will
  # return the appropriate JAVA_home value
  def run_java_home
    `/usr/libexec/java_home`.to_s.strip
  end

end

Version data entries

99 entries across 99 versions & 1 rubygems

Version Path
mortar-0.8.8 lib/mortar/local/java.rb
mortar-0.8.7 lib/mortar/local/java.rb
mortar-0.8.6 lib/mortar/local/java.rb
mortar-0.8.5 lib/mortar/local/java.rb
mortar-0.8.4 lib/mortar/local/java.rb
mortar-0.8.3 lib/mortar/local/java.rb
mortar-0.8.2 lib/mortar/local/java.rb
mortar-0.8.1 lib/mortar/local/java.rb
mortar-0.8.0 lib/mortar/local/java.rb
mortar-0.7.9 lib/mortar/local/java.rb
mortar-0.7.8 lib/mortar/local/java.rb
mortar-0.7.7 lib/mortar/local/java.rb
mortar-0.7.6 lib/mortar/local/java.rb
mortar-0.7.5 lib/mortar/local/java.rb
mortar-0.7.4 lib/mortar/local/java.rb
mortar-0.7.3 lib/mortar/local/java.rb
mortar-0.7.2 lib/mortar/local/java.rb
mortar-0.7.1 lib/mortar/local/java.rb
mortar-0.7.0 lib/mortar/local/java.rb