-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Adds java-cfenv framework #1031
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ddaa856
adds java-cfenv framework
b0c4bfe
addresses comments on java-cfenv framework
0023891
fixes bug with supports logic for cfenv
dbcaf77
fixes bug with logic for SAR
a58b76f
Remove profile inclusion
anthonydahanne bcede67
Merge pull request #1033 from anthonydahanne/java-cfenv-anthony
pivotal-david-osullivan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # Cloud Foundry Java Buildpack | ||
| # Copyright 2013-2023 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. | ||
|
|
||
| # Configuration for the Java CfEnv framework. | ||
| # See https://github.com/pivotal-cf/java-cfenv for library information | ||
|
|
||
| --- | ||
| version: 3.+ | ||
| repository_root: "{default.repository.root}/java-cfenv" | ||
| enabled: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # Java CfEnv Framework | ||
| The Java CfEnv Framework provides the `java-cfenv` library for Spring Boot 3+ applications. This library sets various Spring Boot properties by parsing CloudFoundry variables such as `VCAP_SERVICES`, allowing Spring Boot's autoconfiguration to kick in. | ||
|
|
||
| This is the recommended replacement for Spring AutoReconfiguration library which is deprecated. See the `java-cfenv` <a href="https://github.com/pivotal-cf/java-cfenv">repostitory</a> for more detail. | ||
|
|
||
| It also sets the 'cloud' profile for Spring Boot applications, as the Spring AutoReconfiguration framework did. | ||
|
|
||
| <table> | ||
| <tr> | ||
| <td><strong>Detection Criterion</strong></td> | ||
| <td>Existence of a <tt>spring-boot-3*.jar</tt> file in the application directory or a `Spring-Boot-Version: 3.*` manifest entry</td> | ||
| <td>No existing `java-cfenv` library found</td> | ||
| </tr> | ||
| <tr> | ||
| <td><strong>Tags</strong></td> | ||
| <td><tt>java-cf-env=<version></tt></td> | ||
| </tr> | ||
| </table> | ||
| Tags are printed to standard output by the buildpack detect script |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| # 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' | ||
| require 'java_buildpack/util/spring_boot_utils' | ||
|
|
||
| module JavaBuildpack | ||
| module Framework | ||
|
|
||
| # Encapsulates the detect, compile, and release functionality for enabling cloud auto-reconfiguration in Spring | ||
| # applications. | ||
| class JavaCfEnv < JavaBuildpack::Component::VersionedDependencyComponent | ||
| include JavaBuildpack::Util | ||
|
|
||
| def initialize(context) | ||
| @spring_boot_utils = JavaBuildpack::Util::SpringBootUtils.new | ||
| super(context) | ||
| end | ||
|
|
||
| # (see JavaBuildpack::Component::BaseComponent#compile) | ||
| def compile | ||
| download_jar | ||
| @droplet.additional_libraries << (@droplet.sandbox + jar_name) | ||
| end | ||
|
|
||
| # (see JavaBuildpack::Component::BaseComponent#release) | ||
| def release | ||
| @droplet.additional_libraries << (@droplet.sandbox + jar_name) | ||
| end | ||
|
|
||
| protected | ||
|
|
||
| # (see JavaBuildpack::Component::VersionedDependencyComponent#supports?) | ||
| def supports? | ||
| @configuration['enabled'] && spring_boot_3? && !java_cfenv? | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def spring_boot_3? | ||
| @spring_boot_utils.is?(@application) && Gem::Version.new((@spring_boot_utils.version @application)).release >= | ||
| Gem::Version.new('3.0.0') | ||
| end | ||
|
|
||
| def java_cfenv? | ||
| (@droplet.root + '**/*java-cfenv*.jar').glob.any? | ||
| end | ||
|
|
||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| Spring-Boot-Lib: manifest-lib-value/ | ||
| Main-Class: org.springframework.boot.loader.JarLauncher | ||
| Spring-Boot-Version: 2.1.0.RELEASE |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| Spring-Boot-Lib: manifest-lib-value/ | ||
| Main-Class: org.springframework.boot.loader.JarLauncher | ||
| Spring-Boot-Version: 3.0.0.M1 |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| Spring-Boot-Lib: manifest-lib-value/ | ||
| Spring-Boot-Version: 3.2.5.RELEASE | ||
| Main-Class: org.springframework.boot.loader.JarLauncher | ||
|
|
Empty file.
Empty file.
Empty file.
Empty file.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| # 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 'spec_helper' | ||
| require 'component_helper' | ||
| require 'logging_helper' | ||
| require 'java_buildpack/framework/java_cf_env' | ||
|
|
||
| describe JavaBuildpack::Framework::JavaCfEnv do | ||
| include_context 'with component help' | ||
| include_context 'with console help' | ||
| include_context 'with logging help' | ||
|
|
||
| let(:configuration) { { 'enabled' => true } } | ||
|
|
||
| it 'detects with Spring Boot 3 JAR', | ||
| app_fixture: 'framework_java_cf_boot_3' do | ||
|
|
||
| expect(component.detect).to eq("java-cf-env=#{version}") | ||
| end | ||
|
|
||
| it 'does not detect with Spring Boot < 3', | ||
| app_fixture: 'framework_java_cf_boot_2' do | ||
|
|
||
| expect(component.detect).to be_nil | ||
| end | ||
|
|
||
| it 'does not detect with Spring Boot 3 & java-cfenv present', | ||
| app_fixture: 'framework_java_cf_exists' do | ||
|
|
||
| expect(component.detect).to be_nil | ||
| end | ||
|
|
||
| context do | ||
| let(:configuration) { { 'enabled' => false } } | ||
|
|
||
| it 'does not detect if disabled', | ||
| app_fixture: 'framework_java_cf_boot_3' do | ||
|
|
||
| expect(component.detect).to be_nil | ||
| end | ||
| end | ||
|
|
||
| it 'downloads additional libraries', | ||
| app_fixture: 'framework_java_cf_boot_3', | ||
| cache_fixture: 'stub-java-cfenv.jar' do | ||
|
|
||
| component.compile | ||
|
|
||
| expect(sandbox + "java_cf_env-#{version}.jar").to exist | ||
| end | ||
|
|
||
| it 'adds to additional libraries', | ||
| app_fixture: 'framework_java_cf_boot_3', | ||
| cache_fixture: 'stub-java-cfenv.jar' do | ||
|
|
||
| component.release | ||
|
|
||
| expect(additional_libraries).to include(sandbox + "java_cf_env-#{version}.jar") | ||
| end | ||
|
|
||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.