Skip to content

Commit 5caaa3b

Browse files
committed
Separate Play 2.2.0+ applications
This change adds support for dist and staged Play 2.2 applications as separate types. This was non-obviously implemented previously, but did not make the cut when the big refactoring happened last week. [#59473228]
1 parent 2874ca9 commit 5caaa3b

29 files changed

Lines changed: 543 additions & 350 deletions

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations/All_Tests.xml

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations/Without_Integration_Tests.xml

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

java-buildpack.iml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<module type="RUBY_MODULE" version="4">
3-
<component name="NewModuleRootManager">
3+
<component name="NewModuleRootManager" inherit-compiler-output="false">
44
<content url="file://$MODULE_DIR$">
55
<sourceFolder url="file://$MODULE_DIR$/lib/java_buildpack" isTestSource="false" />
66
<sourceFolder url="file://$MODULE_DIR$/bin" isTestSource="false" />

lib/java_buildpack/util/play/factory.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
# limitations under the License.
1616

1717
require 'java_buildpack/util/play'
18-
require 'java_buildpack/util/play/post22'
18+
require 'java_buildpack/util/play/post22_dist'
19+
require 'java_buildpack/util/play/post22_staged'
1920
require 'java_buildpack/util/play/pre22_dist'
2021
require 'java_buildpack/util/play/pre22_staged'
2122

@@ -30,7 +31,8 @@ class Factory
3031
# @return [JavaBuildpack::Util::Play::Base] the play application delegate
3132
def self.create(application)
3233
candidates = [
33-
Post22.new(application),
34+
Post22Dist.new(application),
35+
Post22Staged.new(application),
3436
Pre22Dist.new(application),
3537
Pre22Staged.new(application)
3638
].select { |candidate| candidate.supports? }

lib/java_buildpack/util/play/post22.rb

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,27 @@ def java_opts
3838
end
3939

4040
def lib_dir
41-
@application.child 'lib'
41+
root + 'lib'
4242
end
4343

4444
def start_script
45-
candidates = @application.glob('bin/*')
46-
if candidates.size == 1
47-
candidates.first
45+
if root
46+
candidates = @application.glob(root + 'bin/*')
47+
candidates.size == 1 ? candidates.first : candidates.find { |candidate| Pathname.new("#{candidate}.bat").exist? }
4848
else
49-
candidates.find { |candidate| Pathname.new("#{candidate}.bat").exist? }
49+
nil
5050
end
5151
end
5252

53+
protected
54+
55+
# Returns the root of the play application
56+
#
57+
# @return [Pathname] the root of the play application
58+
def root
59+
fail "Method 'root' must be defined"
60+
end
61+
5362
end
5463

5564
end
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Encoding: utf-8
2+
# Cloud Foundry Java Buildpack
3+
# Copyright (c) 2013 the original author or authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
require 'java_buildpack/util/play/post22'
18+
19+
module JavaBuildpack::Util::Play
20+
21+
# Encapsulate inspection and modification of Play dist applications up to and including Play 2.1.x.
22+
class Post22Dist < Post22
23+
24+
protected
25+
26+
def root
27+
roots = @application.glob('*').select { |child| child.directory? }
28+
roots.size == 1 ? roots.first : nil
29+
end
30+
31+
end
32+
33+
end
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Encoding: utf-8
2+
# Cloud Foundry Java Buildpack
3+
# Copyright (c) 2013 the original author or authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
require 'java_buildpack/util/play/post22'
18+
19+
module JavaBuildpack::Util::Play
20+
21+
# Encapsulate inspection and modification of Play staged applications from Play 2.2.0 onwards.
22+
class Post22Staged < Post22
23+
24+
protected
25+
26+
def root
27+
@application.child '.'
28+
end
29+
30+
end
31+
32+
end

lib/java_buildpack/util/play/pre22.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ class Pre22 < Base
2424
protected
2525

2626
def start_script
27-
candidate = root
28-
candidate ? candidate + 'start' : nil
27+
root ? root + 'start' : nil
2928
end
3029

3130
protected

lib/java_buildpack/util/play/pre22_dist.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ def lib_dir
4444
end
4545

4646
def root
47-
@application.glob('*').select { |child| child.directory? }.first
47+
roots = @application.glob('*').select { |child| child.directory? }
48+
roots.size == 1 ? roots.first : nil
4849
end
4950

5051
end

0 commit comments

Comments
 (0)