Skip to content

Commit

Permalink
Merge branch '811-dist-zip-args' into main
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Hale <bhale@vmware.com>
  • Loading branch information
nebhale committed Jun 22, 2020
2 parents 03e8eec + 0aa857a commit d1155b1
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 4 deletions.
18 changes: 18 additions & 0 deletions config/dist_zip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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.

# Configuration for the DistZip container
---
arguments:
18 changes: 18 additions & 0 deletions config/dist_zip_like.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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.

# Configuration for the DistZip container
---
arguments:
11 changes: 9 additions & 2 deletions docs/container-dist_zip.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,18 @@ The Dist Zip Container allows applications packaged in [`distZip`-style][] to be
</table>
Tags are printed to standard output by the buildpack detect script

If the application uses Spring, [Spring profiles][] can be specified by setting the [`SPRING_PROFILES_ACTIVE`][] environment variable. This is automatically detected and used by Spring. The Spring Auto-reconfiguration Framework will specify the `cloud` profile in addition to any others.
If the application uses Spring, [Spring profiles][] can be specified by setting the [`SPRING_PROFILES_ACTIVE`][] environment variable. This is automatically detected and used by Spring. The Spring Auto-reconfiguration Framework will specify the `cloud` profile in addition to any others.

## Configuration
The Dist Zip Container cannot be configured.
For general information on configuring the buildpack, including how to specify configuration values through environment variables, refer to [Configuration and Extension][].

The container can be configured by modifying the `config/dist_zip.yml` file in the buildpack fork.

| Name | Description
| ---- | -----------
| `arguments` | Optional command line arguments to be passed to the start script. The arguments are specified as a single YAML scalar in plain style or enclosed in single or double quotes.

[Configuration and Extension]: ../README.md#configuration-and-extension
[`distZip`-style]: http://www.gradle.org/docs/current/userguide/application_plugin.html
[Spring profiles]:http://blog.springsource.com/2011/02/14/spring-3-1-m1-introducing-profile/
[`SPRING_PROFILES_ACTIVE`]: http://static.springsource.org/spring/docs/3.1.x/javadoc-api/org/springframework/core/env/AbstractEnvironment.html#ACTIVE_PROFILES_PROPERTY_NAME
11 changes: 9 additions & 2 deletions lib/java_buildpack/container/dist_zip_like.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ def release
@droplet.environment_variables.as_env_vars,
@droplet.java_home.as_env_var,
'exec',
qualify_path(start_script(root), @droplet.root)
qualify_path(start_script(root), @droplet.root),
arguments
].flatten.compact.join(' ')
end

Expand Down Expand Up @@ -76,11 +77,17 @@ def supports?

private

ARGUMENTS_PROPERTY = 'arguments'

PATTERN_APP_CLASSPATH = /^declare -r app_classpath=\"(.*)\"$/.freeze

PATTERN_CLASSPATH = /^CLASSPATH=(.*)$/.freeze

private_constant :PATTERN_APP_CLASSPATH, :PATTERN_CLASSPATH
private_constant :ARGUMENTS_PROPERTY, :PATTERN_APP_CLASSPATH, :PATTERN_CLASSPATH

def arguments
@configuration[ARGUMENTS_PROPERTY]
end

def augment_app_classpath(content)
additional_classpath = (@droplet.additional_libraries + @droplet.root_libraries).sort.map do |library|
Expand Down
10 changes: 10 additions & 0 deletions spec/java_buildpack/container/dist_zip_like_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,14 @@
'$PWD/bin/application')
end

context do
let(:configuration) { { 'arguments' => 'some arguments' } }

it 'returns command line arguments when they are specified',
app_fixture: 'container_dist_zip' do

expect(component.release).to end_with('some arguments')
end
end

end
10 changes: 10 additions & 0 deletions spec/java_buildpack/container/dist_zip_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,14 @@
expect(component.detect).to be_nil
end

context do
let(:configuration) { { 'arguments' => 'some arguments' } }

it 'returns command line arguments when they are specified',
app_fixture: 'container_dist_zip' do

expect(component.release).to end_with('some arguments')
end
end

end

0 comments on commit d1155b1

Please sign in to comment.