Skip to content

Commit 7efce76

Browse files
author
Glyn Normington
committed
Improve Play detection
As well as a start script, a Play application now also needs a suitable Play JAR in the lib directory. Add Play to the README. [#51899933]
1 parent 0063a69 commit 7efce76

6 files changed

Lines changed: 33 additions & 4 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Additional documentation can be found by following the links below.
2626
* [Design](docs/design.md)
2727
* Standard Containers
2828
* [Java Main Class](docs/container-java-main.md) ([Configuration](docs/container-java-main.md#configuration))
29+
* [Play](docs/container-play.md)
2930
* [Tomcat](docs/container-tomcat.md) ([Configuration](docs/container-tomcat.md))
3031
* Standard Frameworks
3132
* [`JAVA_OPTS`](docs/framework-java_opts.md) ([Configuration](docs/framework-java_opts.md#configuration))

docs/container-play.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# JPlay Container
2+
The Play Container allows Play applications to be run.
3+
4+
<table>
5+
<tr>
6+
<td><strong>Detection Criteria</strong></td><td><tt>start</tt> script and <tt>lib/play.play_*.jar</tt> exist in the application</td>
7+
</tr>
8+
<tr>
9+
<td><strong>Tags</strong></td><td><tt>Play</tt></td>
10+
</tr>
11+
</table>
12+
Tags are printed to standard output by the buildpack detect script
13+
14+
## Configuration
15+
The Play Container cannot be configured.
16+
17+

lib/java_buildpack/container/play.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def initialize(context)
4343
# @return [String] returns +Play+ if and only if the application has a +start+ script, otherwise
4444
# returns +nil+
4545
def detect
46-
play_script? ? PLAY_TAG : nil
46+
play_app? ? PLAY_TAG : nil
4747
end
4848

4949
# Makes the +start+ script executable.
@@ -69,8 +69,11 @@ def release
6969

7070
PLAY_TAG = 'Play'.freeze
7171

72-
def play_script?
73-
File.exists?(@start_script_path) && !File.directory?(@start_script_path)
72+
PLAY_JAR_PATTERN = 'lib/play.play_*.jar'.freeze
73+
74+
def play_app?
75+
File.exists?(@start_script_path) && !File.directory?(@start_script_path) &&
76+
!Dir.glob(File.join(@app_dir, PLAY_JAR_PATTERN)).empty?
7477
end
7578

7679
def java_opts

spec/fixtures/container_play/lib/play.play_0.0-0.0.0.jar

Whitespace-only changes.

spec/fixtures/container_play_like/start

Whitespace-only changes.

spec/java_buildpack/container/play_spec.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,22 @@ module JavaBuildpack::Container
4040
expect(detected).to be_nil
4141
end
4242

43-
it 'should detect an application with a start script' do
43+
it 'should detect an application with a start script and a suitable Play JAR' do
4444
detected = Play.new(
4545
:app_dir => 'spec/fixtures/container_play',
4646
:configuration => {}).detect
4747

4848
expect(detected).to eq('Play')
4949
end
5050

51+
it 'should not detect an application with a start script but no suitable Play JAR' do
52+
detected = Play.new(
53+
:app_dir => 'spec/fixtures/container_play_like',
54+
:configuration => {}).detect
55+
56+
expect(detected).to be_nil
57+
end
58+
5159
it 'should make the start script executable in the compile step' do
5260
play = Play.new(
5361
:app_dir => 'spec/fixtures/container_play',

0 commit comments

Comments
 (0)