Class: JavaBuildpackUtils::Jre::Compile
- Inherits:
-
Object
- Object
- JavaBuildpackUtils::Jre::Compile
- Defined in:
- lib/java-buildpack-utils/jre/compile.rb
Overview
A class containing the functionality required to download and unpack a JRE for a user based on input from the user
Instance Method Summary collapse
-
#initialize(app_dir, app_cache_dir) ⇒ Compile
constructor
Creates a new instance, passing in the application directory and application cache directories used during compilation.
-
#run ⇒ void
The execution entry point for compilation.
Constructor Details
#initialize(app_dir, app_cache_dir) ⇒ Compile
Creates a new instance, passing in the application directory and application cache directories used during compilation
28 29 30 31 32 |
# File 'lib/java-buildpack-utils/jre/compile.rb', line 28 def initialize(app_dir, app_cache_dir) @app_dir = app_dir @global_cache = BuildpackUtils::GlobalCache.new @selected_jre = JavaBuildpackUtils::Jre::SelectedJre.new(app_dir) end |
Instance Method Details
#run ⇒ void
This method returns an undefined value.
The execution entry point for compilation. This method is responsible for downloading the correct version of Java and unpacking it to the application’s runtime directory.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/java-buildpack-utils/jre/compile.rb', line 38 def run uri = @selected_jre.uri download_start_time = Time.now print "-----> Downloading #{@selected_jre.vendor} #{@selected_jre.version} JRE from #{uri} " @global_cache.get(@selected_jre.id, uri) do |file| puts "(#{(Time.now - download_start_time).duration})" = Time.now print "-----> Expanding JRE to #{JavaBuildpackUtils::Jre::JAVA_HOME} " absolute_java_home = File.join @app_dir, JavaBuildpackUtils::Jre::JAVA_HOME `rm -rf #{absolute_java_home}` `mkdir -p #{absolute_java_home}` `tar xzvf #{file.path} -C #{absolute_java_home} --strip 1 2>&1` puts "(#{(Time.now - ).duration})" end end |