Skip to content

Commit 50e2a4c

Browse files
committed
Support for PropertiesLauncher
Spring Boot has a third kind of launcher, the PropertiesLauncher. Previously, we did not add a --server.port flag when starting this kind of launcher. This change ensures that we do. [#58809612]
1 parent a1e96b4 commit 50e2a4c

4 files changed

Lines changed: 34 additions & 2 deletions

File tree

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ GEM
1212
parser (2.0.0)
1313
ast (~> 1.1)
1414
slop (~> 3.4, >= 3.4.5)
15-
powerpack (0.0.8)
15+
powerpack (0.0.9)
1616
rainbow (1.1.4)
1717
rake (10.1.0)
1818
redcarpet (3.0.0)

lib/java_buildpack/container/main.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def manifest_class_path
7676
end
7777

7878
def port
79-
main_class =~ /^org\.springframework\.boot\.loader\.[JW]arLauncher$/ ? '--server.port=$PORT' : nil
79+
main_class =~ /^org\.springframework\.boot\.loader\.(?:[JW]ar|Properties)Launcher$/ ? '--server.port=$PORT' : nil
8080
end
8181

8282
end
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Main-Class: org.springframework.boot.loader.PropertiesLauncher

spec/java_buildpack/container/main_spec.rb

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,17 @@ module JavaBuildpack::Container
154154
expect(command).to eq('test-java-home/bin/java -cp . org.springframework.boot.loader.WarLauncher --server.port=$PORT')
155155
end
156156

157+
it 'should release Spring boot applications with a PropertiesLauncher in the MANIFEST.MF by specifying a port' do
158+
command = Main.new(
159+
app_dir: 'spec/fixtures/container_main_spring_boot_properties_launcher',
160+
java_home: 'test-java-home',
161+
java_opts: [],
162+
configuration: {}
163+
).release
164+
165+
expect(command).to eq('test-java-home/bin/java -cp . org.springframework.boot.loader.PropertiesLauncher --server.port=$PORT')
166+
end
167+
157168
it 'should release Spring boot applications with a JarLauncher in the configuration by specifying a port' do
158169
Dir.mktmpdir do |root|
159170
lib_directory = File.join(root, '.lib')
@@ -194,6 +205,26 @@ module JavaBuildpack::Container
194205
end
195206
end
196207

208+
it 'should release Spring boot applications with a PropertiesLauncher in the configuration by specifying a port' do
209+
Dir.mktmpdir do |root|
210+
lib_directory = File.join(root, '.lib')
211+
Dir.mkdir lib_directory
212+
213+
command = Main.new(
214+
app_dir: root,
215+
java_home: 'test-java-home',
216+
java_opts: [],
217+
lib_directory: lib_directory,
218+
configuration: {
219+
'java_main_class' => 'org.springframework.boot.loader.PropertiesLauncher',
220+
'arguments' => 'some arguments'
221+
}
222+
).release
223+
224+
expect(command).to eq('test-java-home/bin/java -cp . org.springframework.boot.loader.PropertiesLauncher some arguments --server.port=$PORT')
225+
end
226+
end
227+
197228
end
198229

199230
end

0 commit comments

Comments
 (0)