Skip to content

Commit 68d20ef

Browse files
author
Daniel Mikusa
authored
Add deprecation warnings around SAR/SCC (#947)
- Add a deprecation warning if you are manually including Spring Cloud Connectors in your app - Add a deprecation warning if you are relying on Spring Auto Reconfiguration, which has Spring Cloud Connectors shaded into it - Do not include Spring Auto Reconfiguration if java-cfenv JARs are present in the app Signed-off-by: Daniel Mikusa <[email protected]>
1 parent 25db632 commit 68d20ef

File tree

8 files changed

+89
-2
lines changed

8 files changed

+89
-2
lines changed

lib/java_buildpack/framework/spring_auto_reconfiguration.rb

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,19 @@ module Framework
2525
# applications.
2626
class SpringAutoReconfiguration < JavaBuildpack::Component::VersionedDependencyComponent
2727

28+
def initialize(context)
29+
super(context)
30+
@logger = JavaBuildpack::Logging::LoggerFactory.instance.get_logger SpringAutoReconfiguration
31+
end
32+
2833
# (see JavaBuildpack::Component::BaseComponent#compile)
2934
def compile
35+
log_warning_scc_manual if spring_cloud_connectors?
36+
3037
download_jar
3138
@droplet.additional_libraries << (@droplet.sandbox + jar_name)
39+
40+
log_warning_sar_scc_auto
3241
end
3342

3443
# (see JavaBuildpack::Component::BaseComponent#release)
@@ -40,10 +49,52 @@ def release
4049

4150
# (see JavaBuildpack::Component::VersionedDependencyComponent#supports?)
4251
def supports?
43-
@configuration['enabled'] && (@droplet.root + '**/*spring-core*.jar').glob.any?
52+
@configuration['enabled'] && spring? && !java_cfenv?
4453
end
4554

46-
end
55+
private
56+
57+
def spring?
58+
(@droplet.root + '**/*spring-core*.jar').glob.any?
59+
end
4760

61+
def java_cfenv?
62+
(@droplet.root + '**/*java-cfenv*.jar').glob.any?
63+
end
64+
65+
def spring_cloud_connectors?
66+
(@droplet.root + '**/spring-cloud-cloudfoundry-connector*.jar').glob.any? ||
67+
(@droplet.root + '**/spring-cloud-spring-service-connector*.jar').glob.any?
68+
end
69+
70+
def log_warning_scc_manual
71+
@logger.warn do
72+
'ATTENTION: The Spring Cloud Connectors library is present in your application. This library ' \
73+
'has been in maintenance mode since July 2019 and will stop receiving all updates after ' \
74+
'Dec 2022.'
75+
end
76+
@logger.warn do
77+
'Please migrate to java-cfenv immediately. See https://via.vmw.com/EhzD for migration instructions.' \
78+
end
79+
end
80+
81+
def log_warning_sar_scc_auto
82+
@logger.warn do
83+
'ATTENTION: The Spring Auto Reconfiguration and shaded Spring Cloud Connectors libraries are ' \
84+
'being installed. These projects have been deprecated, are no longer receiving updates and should ' \
85+
'not be used going forward.'
86+
end
87+
@logger.warn do
88+
'If you are not using these libraries, set `JBP_CONFIG_SPRING_AUTO_RECONFIGURATION=\'{enabled: false}\'` ' \
89+
'to disable their installation and clear this warning message. The buildpack will switch its default ' \
90+
'to disable by default after Aug 2022. Spring Auto Reconfiguration and its shaded Spring Cloud ' \
91+
'Connectors will be removed from the buildpack after Dec 2022.'
92+
end
93+
@logger.warn do
94+
'If you are using these libraries, please migrate to java-cfenv immediately. ' \
95+
'See https://via.vmw.com/EhzD for migration instructions. Once you upgrade this message will go away.'
96+
end
97+
end
98+
end
4899
end
49100
end

spec/fixtures/framework_auto_reconfiguration_java_cfenv/WEB-INF/lib/java-cfenv-2.1.2.RELEASE.jar

Whitespace-only changes.

spec/fixtures/framework_auto_reconfiguration_java_cfenv/WEB-INF/lib/java-cfenv-boot-2.1.2.RELEASE.jar

Whitespace-only changes.

spec/fixtures/framework_auto_reconfiguration_java_cfenv/WEB-INF/lib/java-cfenv-jdbc-2.1.2.RELEASE.jar

Whitespace-only changes.

spec/fixtures/framework_auto_reconfiguration_java_cfenv/WEB-INF/lib/spring-core-3.2.3.RELEASE.jar

Whitespace-only changes.

spec/fixtures/framework_auto_reconfiguration_scc/WEB-INF/lib/spring-cloud-cloudfoundry-connector-1.2.3.jar

Whitespace-only changes.

spec/fixtures/framework_auto_reconfiguration_scc/WEB-INF/lib/spring-core-3.2.3.RELEASE.jar

Whitespace-only changes.

spec/java_buildpack/framework/spring_auto_reconfiguration_spec.rb

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@
1717

1818
require 'spec_helper'
1919
require 'component_helper'
20+
require 'logging_helper'
2021
require 'java_buildpack/framework/spring_auto_reconfiguration'
2122

2223
describe JavaBuildpack::Framework::SpringAutoReconfiguration do
2324
include_context 'with component help'
25+
include_context 'with console help'
26+
include_context 'with logging help'
2427

2528
let(:configuration) { { 'enabled' => true } }
2629

@@ -36,10 +39,43 @@
3639
expect(component.detect).to eq("spring-auto-reconfiguration=#{version}")
3740
end
3841

42+
it 'does not detect with Spring JAR and java-cfenv',
43+
app_fixture: 'framework_auto_reconfiguration_java_cfenv' do
44+
45+
expect(component.detect).to be_nil
46+
end
47+
3948
it 'does not detect without Spring JAR' do
4049
expect(component.detect).to be_nil
4150
end
4251

52+
it 'warns if SCC is present',
53+
cache_fixture: 'stub-auto-reconfiguration.jar',
54+
app_fixture: 'framework_auto_reconfiguration_scc' do
55+
56+
component.compile
57+
58+
expect(stderr.string).to match(/ATTENTION: The Spring Cloud Connectors library is present in your application/)
59+
end
60+
61+
it 'does not warn when SCC is missing',
62+
cache_fixture: 'stub-auto-reconfiguration.jar',
63+
app_fixture: 'framework_auto_reconfiguration_servlet_3' do
64+
65+
component.compile
66+
67+
expect(stderr.string).not_to match(/ATTENTION: The Spring Cloud Connectors library is present in your application/)
68+
end
69+
70+
it 'warns if SAR is contributed',
71+
cache_fixture: 'stub-auto-reconfiguration.jar',
72+
app_fixture: 'framework_auto_reconfiguration_servlet_3' do
73+
74+
component.compile
75+
76+
expect(stderr.string).to match(/ATTENTION: The Spring Auto Reconfiguration and shaded Spring Cloud/)
77+
end
78+
4379
context do
4480
let(:configuration) { { 'enabled' => false } }
4581

0 commit comments

Comments
 (0)