@@ -56,11 +56,11 @@ def detect
5656 def compile
5757 puts BUILDPACK_MESSAGE % @buildpack_version
5858
59- container = component_detection ( @containers ) . first
59+ container = component_detection ( 'container' , @containers , true ) . first
6060 fail 'No container can run this application' unless container
6161
62- component_detection ( @jres ) . first . compile
63- component_detection ( @frameworks ) . each { |framework | framework . compile }
62+ component_detection ( 'JRE' , @jres , true ) . first . compile
63+ component_detection ( 'framework' , @frameworks , false ) . each { |framework | framework . compile }
6464 container . compile
6565 end
6666
@@ -69,11 +69,11 @@ def compile
6969 #
7070 # @return [String] The payload required to run the application.
7171 def release
72- container = component_detection ( @containers ) . first
72+ container = component_detection ( 'container' , @containers , true ) . first
7373 fail 'No container can run this application' unless container
7474
75- component_detection ( @jres ) . first . release
76- component_detection ( @frameworks ) . each { |framework | framework . release }
75+ component_detection ( 'JRE' , @jres , true ) . first . release
76+ component_detection ( 'framework' , @frameworks , false ) . each { |framework | framework . release }
7777 command = container . release
7878
7979 payload = {
@@ -118,8 +118,26 @@ def initialize(app_dir, application)
118118 java_opts , app_dir )
119119 end
120120
121- def component_detection ( components )
122- components . select { |component | component . detect }
121+ def component_detection ( type , components , unique )
122+ detected , _tags = detection type , components , unique
123+ detected
124+ end
125+
126+ def detection ( type , components , unique )
127+ detected = [ ]
128+ tags = [ ]
129+
130+ components . each do |component |
131+ result = component . detect
132+
133+ if result
134+ detected << component
135+ tags << result
136+ end
137+ end
138+
139+ fail "Application can be run by more than one #{ type } : #{ names detected } " if unique && detected . size > 1
140+ [ detected , tags ]
123141 end
124142
125143 def instantiate ( components , additional_libraries , application , java_home , java_opts , root )
@@ -159,19 +177,7 @@ def require_component(component)
159177 end
160178
161179 def tag_detection ( type , components , unique )
162- detected = [ ]
163- tags = [ ]
164-
165- components . each do |component |
166- result = component . detect
167-
168- if result
169- detected << component
170- tags << result
171- end
172- end
173-
174- fail "Application can be run by more than one #{ type } : #{ names detected } " if unique && tags . size > 1
180+ _detected , tags = detection type , components , unique
175181 tags
176182 end
177183
0 commit comments