Skip to content

Commit 54ecf89

Browse files
committed
Merge 114796139-use-library-from-manifest to master
[Completes #114796139]
2 parents a87f57f + 4e00a7f commit 54ecf89

3 files changed

Lines changed: 29 additions & 4 deletions

File tree

lib/java_buildpack/util/spring_boot_utils.rb

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,18 @@ def is?(application)
4343
# @param [Droplet] droplet the droplet to search
4444
# @return [String] the lib directory of Spring Boot used by the application
4545
def lib(droplet)
46-
return boot_inf_lib_dir(droplet) if boot_inf_lib_dir(droplet).exist?
47-
return web_inf_lib_dir(droplet) if web_inf_lib_dir(droplet).exist?
48-
return lib_dir(droplet) if lib_dir(droplet).exist?
46+
candidate = manifest_lib_dir(droplet)
47+
return candidate if candidate && candidate.exist?
48+
49+
candidate = boot_inf_lib_dir(droplet)
50+
return candidate if candidate && candidate.exist?
51+
52+
candidate = web_inf_lib_dir(droplet)
53+
return candidate if candidate && candidate.exist?
54+
55+
candidate = lib_dir(droplet)
56+
return candidate if candidate && candidate.exist?
57+
4958
fail('No lib directory found')
5059
end
5160

@@ -60,14 +69,21 @@ def version(application)
6069

6170
private
6271

72+
SPRING_BOOT_LIB = 'Spring-Boot-Lib'.freeze
73+
6374
SPRING_BOOT_VERSION = 'Spring-Boot-Version'.freeze
6475

65-
private_constant :SPRING_BOOT_VERSION
76+
private_constant :SPRING_BOOT_LIB, :SPRING_BOOT_VERSION
6677

6778
def boot_inf_lib_dir(droplet)
6879
droplet.root + 'BOOT-INF/lib'
6980
end
7081

82+
def manifest_lib_dir(droplet)
83+
value = JavaBuildpack::Util::JavaMainUtils.manifest(droplet)[SPRING_BOOT_LIB]
84+
value ? droplet.root + value : nil
85+
end
86+
7187
def lib_dir(droplet)
7288
droplet.root + 'lib'
7389
end
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
Spring-Boot-Lib: manifest-lib-value/
12
Spring-Boot-Version: 1.2.5.RELEASE
23
Main-Class: org.springframework.boot.loader.JarLauncher
34

spec/java_buildpack/util/spring_boot_utils_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@
8383
expect(utils.lib(droplet)).to eq(droplet.root + 'lib')
8484
end
8585

86+
it 'returns manifest value as lib directory',
87+
app_fixture: 'container_main_spring_boot_jar_launcher' do
88+
89+
FileUtils.mkdir_p(app_dir + 'manifest-lib-value')
90+
91+
expect(utils.lib(droplet)).to eq(droplet.root + 'manifest-lib-value/')
92+
end
93+
8694
it 'fails if there are no lib directories' do
8795
expect { utils.lib(droplet) }.to raise_error
8896
end

0 commit comments

Comments
 (0)