Skip to content

Commit f97e6fe

Browse files
Merge pull request #1056 from cloudfoundry/java-cfenv-improvement
Improvement to condition to trigger java-cfenv framework
2 parents 9e8f9be + 1b541fc commit f97e6fe

File tree

6 files changed

+19
-3
lines changed

6 files changed

+19
-3
lines changed

docs/framework-java-cfenv.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ It also sets the 'cloud' profile for Spring Boot applications, as the Spring Aut
88
<table>
99
<tr>
1010
<td><strong>Detection Criterion</strong></td>
11-
<td>Existence of a <tt>spring-boot-3*.jar</tt> file in the application directory or a `Spring-Boot-Version: 3.*` manifest entry</td>
11+
<td>Existence of a `Spring-Boot-Version: 3.*` manifest entry</td>
1212
<td>No existing `java-cfenv` library found</td>
1313
</tr>
1414
<tr>

lib/java_buildpack/framework/java_cf_env.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ def supports?
5353
private
5454

5555
def spring_boot_3?
56-
@spring_boot_utils.is?(@application) && Gem::Version.new((@spring_boot_utils.version @application)).release >=
57-
Gem::Version.new('3.0.0')
56+
@spring_boot_utils.is?(@application) &&
57+
Gem::Version.new((@spring_boot_utils.version_strict @application)).release >= Gem::Version.new('3.0.0')
5858
end
5959

6060
def java_cfenv?

lib/java_buildpack/util/spring_boot_utils.rb

+8
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@ def version(application)
8787
@jar_finder.version(application)
8888
end
8989

90+
# The version of Spring Boot used by the application - only considers the MANIFEST entry
91+
#
92+
# @param [Application] application the application to search
93+
# @return [String] the version of Spring Boot used by the application
94+
def version_strict(application)
95+
JavaBuildpack::Util::JavaMainUtils.manifest(application)[SPRING_BOOT_VERSION]
96+
end
97+
9098
private
9199

92100
SPRING_BOOT_LIB = 'Spring-Boot-Lib'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Main-Class: org.springframework.boot.loader.JarLauncher
2+

spec/fixtures/framework_java_not_spring_boot3/WEB-INF/lib/spring-boot-3.2.3.RELEASE.jar

Whitespace-only changes.

spec/java_buildpack/framework/java_cfenv_spec.rb

+6
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@
3939
expect(component.detect).to be_nil
4040
end
4141

42+
it 'does not detect with Spring Boot 3 named jar but not Spring Boot 3 Manifest',
43+
app_fixture: 'framework_java_not_spring_boot3' do
44+
45+
expect(component.detect).to be_nil
46+
end
47+
4248
it 'does not detect with Spring Boot 3 & java-cfenv present',
4349
app_fixture: 'framework_java_cf_exists' do
4450

0 commit comments

Comments
 (0)