forked from cloudfoundry/java-buildpack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
spring_auto_reconfiguration.rb
109 lines (90 loc) · 4 KB
/
spring_auto_reconfiguration.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# frozen_string_literal: true
# Cloud Foundry Java Buildpack
# Copyright 2013-2020 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require 'java_buildpack/component/versioned_dependency_component'
require 'java_buildpack/framework'
module JavaBuildpack
module Framework
# Encapsulates the detect, compile, and release functionality for enabling cloud auto-reconfiguration in Spring
# applications.
class SpringAutoReconfiguration < JavaBuildpack::Component::VersionedDependencyComponent
def initialize(context)
super(context)
@logger = JavaBuildpack::Logging::LoggerFactory.instance.get_logger SpringAutoReconfiguration
end
# (see JavaBuildpack::Component::BaseComponent#compile)
def compile
log_warning_scc_manual if spring_cloud_connectors?
return if java_cf_env_framework?
download_jar
@droplet.additional_libraries << (@droplet.sandbox + jar_name)
log_warning_sar_scc_auto
end
# (see JavaBuildpack::Component::BaseComponent#release)
def release
return if java_cf_env_framework?
@droplet.additional_libraries << (@droplet.sandbox + jar_name)
end
protected
# (see JavaBuildpack::Component::VersionedDependencyComponent#supports?)
def supports?
@configuration['enabled'] && spring? && !java_cfenv?
end
private
def spring?
(@droplet.root + '**/*spring-core*.jar').glob.any?
end
def java_cfenv?
(@droplet.root + '**/*java-cfenv*.jar').glob.any? || java_cf_env_framework?
end
def java_cf_env_framework?
@droplet.additional_libraries.any? do |additional_library|
additional_library.instance_variable_get(:@pathname).fnmatch?('*java_cf_env*.jar')
end
end
def spring_cloud_connectors?
(@droplet.root + '**/spring-cloud-cloudfoundry-connector*.jar').glob.any? ||
(@droplet.root + '**/spring-cloud-spring-service-connector*.jar').glob.any?
end
def log_warning_scc_manual
@logger.warn do
'ATTENTION: The Spring Cloud Connectors library is present in your application. This library ' \
'has been in maintenance mode since July 2019 and will stop receiving all updates after ' \
'Mar 2024.'
end
@logger.warn do
'Please migrate to java-cfenv immediately. See https://via.vmw.com/EiBW for migration instructions.' \
end
end
def log_warning_sar_scc_auto
@logger.warn do
'ATTENTION: The Spring Auto Reconfiguration and shaded Spring Cloud Connectors libraries are ' \
'being installed. These projects have been deprecated, are no longer receiving updates and should ' \
'not be used going forward.'
end
@logger.warn do
'If you are not using these libraries, set `JBP_CONFIG_SPRING_AUTO_RECONFIGURATION=\'{enabled: false}\'` ' \
'to disable their installation and clear this warning message. The buildpack will switch its default ' \
'to disable by default after March 2023. Spring Auto Reconfiguration and its shaded Spring Cloud ' \
'Connectors will be removed from the buildpack after March 2024.'
end
@logger.warn do
'If you are using these libraries, please migrate to java-cfenv immediately. ' \
'See https://via.vmw.com/EiBW for migration instructions. Once you upgrade this message will go away.'
end
end
end
end
end