1515# limitations under the License.
1616
1717require 'java_buildpack'
18+ require 'java_buildpack/buildpack_version'
1819require 'java_buildpack/component/additional_libraries'
1920require 'java_buildpack/component/application'
2021require 'java_buildpack/component/droplet'
@@ -39,8 +40,6 @@ class Buildpack
3940 # this application. If no container can run the application, the array will be empty
4041 # (+[]+).
4142 def detect
42- diagnose_git_info false
43-
4443 tags = tag_detection ( 'container' , @containers , true )
4544 tags . concat tag_detection ( 'JRE' , @jres , true ) unless tags . empty?
4645 tags . concat tag_detection ( 'framework' , @frameworks , false ) unless tags . empty?
@@ -54,7 +53,7 @@ def detect
5453 #
5554 # @return [Void]
5655 def compile
57- diagnose_git_info true
56+ puts BUILDPACK_MESSAGE % @buildpack_version
5857
5958 container = component_detection ( @containers ) . first
6059 fail 'No container can run this application' unless container
@@ -69,8 +68,6 @@ def compile
6968 #
7069 # @return [String] The payload required to run the application.
7170 def release
72- diagnose_git_info false
73-
7471 container = component_detection ( @containers ) . first
7572 fail 'No container can run this application' unless container
7673
@@ -93,14 +90,13 @@ def release
9390
9491 private
9592
96- DEFAULT_BUILDPACK_MESSAGE = '-----> Java Buildpack source: unknown' . freeze
97-
98- GIT_DIR = Pathname . new ( __FILE__ ) . dirname + '../../.git'
93+ BUILDPACK_MESSAGE = '-----> Java Buildpack Version: %s' . freeze
9994
10095 LOAD_ROOT = Pathname . new ( __FILE__ ) . dirname + '..'
10196
10297 def initialize ( app_dir , application )
103- @logger = Logging ::LoggerFactory . instance . get_logger Buildpack
98+ @logger = Logging ::LoggerFactory . instance . get_logger Buildpack
99+ @buildpack_version = BuildpackVersion . new
104100
105101 log_environment_variables
106102
@@ -123,31 +119,6 @@ def component_detection(components)
123119 components . select { |component | component . detect }
124120 end
125121
126- def diagnose_git_info ( print )
127- if system ( "git --git-dir=#{ GIT_DIR } status 2>/dev/null 1>/dev/null" )
128- remote_url = diagnose_remote
129- head_commit_sha = diagnose_head_commit
130- puts "-----> Java Buildpack source: #{ remote_url } ##{ head_commit_sha } " if print
131- else
132- @logger . debug { DEFAULT_BUILDPACK_MESSAGE }
133- puts DEFAULT_BUILDPACK_MESSAGE if print
134- end
135- end
136-
137- def diagnose_head_commit
138- git 'rev-parse --short HEAD' , 'git HEAD commit: %s'
139- end
140-
141- def diagnose_remote
142- git 'config --get remote.origin.url' , 'git remote: %s'
143- end
144-
145- def git ( command , message )
146- result = `git --git-dir=#{ GIT_DIR } #{ command } ` . chomp
147- @logger . debug { message % result }
148- result
149- end
150-
151122 def instantiate ( components , additional_libraries , application , java_home , java_opts , root )
152123 components . map do |component |
153124 @logger . debug { "Instantiating #{ component } " }
0 commit comments