Skip to content

Commit eadd0bb

Browse files
committed
Merge 49321577-which-java-system-properties to master
[Completes #49321577]
2 parents 3631401 + e3567d6 commit eadd0bb

15 files changed

Lines changed: 147 additions & 46 deletions

File tree

bin/compile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17+
$stdout.sync = true
1718
$:.unshift File.expand_path("../../lib", __FILE__)
19+
1820
require 'java_buildpack'
1921

2022
build_dir = ARGV[0]

bin/detect

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17+
$stdout.sync = true
1718
$:.unshift File.expand_path("../../lib", __FILE__)
19+
1820
require 'java_buildpack'
1921

2022
build_dir = ARGV[0]

bin/release

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17+
$stdout.sync = true
1718
$:.unshift File.expand_path("../../lib", __FILE__)
19+
1820
require 'java_buildpack'
1921

2022
build_dir = ARGV[0]

java-buildpack.gemspec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ Gem::Specification.new do |s|
2929

3030
s.required_ruby_version = '>= 1.9.3'
3131

32+
s.add_dependency 'java-buildpack-utils', '~> 1.0'
33+
3234
s.add_development_dependency 'bundler', '~> 1.3'
3335
s.add_development_dependency 'rake', '~> 10.0'
3436
s.add_development_dependency 'redcarpet', '~> 2.2'

lib/java-buildpack/compile.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,21 @@
1616
# Encapsulates the compilation functionality in the Java buildpack
1717
class JavaBuildpack::Compile
1818

19-
# Creates a new instance, passing in the application directory used during compilation
19+
# Creates a new instance, passing in the application directory and application cache directories used during
20+
# compilation
2021
#
2122
# @param [String] app_dir The application directory used during compilation
2223
# @param [String] app_cache_dir The application cache directory used during compilation
2324
def initialize(app_dir, app_cache_dir)
24-
25+
@jre = JavaBuildpackUtils::Jre::Compile.new(app_dir, app_cache_dir)
2526
end
2627

2728
# The execution entry point for detection. This method is responsible for identifying all of the components that are
2829
# that which to participate in the buildpack and returning their names.
2930
#
3031
# @return [void]
3132
def run
32-
33+
@jre.run
3334
end
3435

3536
end

lib/java-buildpack/detect.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,16 @@ class JavaBuildpack::Detect
2020
#
2121
# @param [String] app_dir The application directory used during detection
2222
def initialize(app_dir)
23-
23+
@jre = JavaBuildpackUtils::Jre::Detect.new(app_dir)
2424
end
2525

2626
# The execution entry point for detection. This method is responsible for identifying all of the components that are
2727
# that which to participate in the buildpack and returning their names.
2828
#
2929
# @return [Array<String>] the names of components that wish to participate in the buildpack
3030
def run
31-
[]
31+
components = []
32+
components << @jre.run
3233
end
3334

3435
end

lib/java-buildpack/release.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,25 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16+
require 'yaml'
17+
1618
# Encapsulates the release functionality in the Java buildpack
1719
class JavaBuildpack::Release
1820

1921
# Creates a new instance, passing in the application directory used during release
2022
#
2123
# @param [String] app_dir The application directory used during release
2224
def initialize(app_dir)
23-
25+
@jre = JavaBuildpackUtils::Jre::Release.new(app_dir)
2426
end
2527

2628
# The execution entry point for release. This method is responsible for generating a payload describing the execution
2729
# command used to start the application.
2830
#
2931
# @return [String] the YAML formatted payload describing the execution command used to start the application
3032
def run
33+
java_home = @jre.run
34+
3135
{
3236
addons: [],
3337
config_vars: {},

lib/java_buildpack.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
module JavaBuildpack
1818
end
1919

20+
require 'java_buildpack_utils'
21+
2022
require 'java-buildpack/compile'
2123
require 'java-buildpack/detect'
2224
require 'java-buildpack/release'

spec/bin/compile_spec.rb

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,25 @@
1818

1919
describe 'compile' do
2020

21-
it 'should return zero if the compile is successful' do
22-
# TODO Implement test as things are filled out
21+
before do
22+
@previous_value = ENV['BUILDPACK_CACHE']
23+
ENV['BUILDPACK_CACHE'] = Dir.tmpdir
2324
end
2425

25-
it 'should return non-zero if an error occurs' do
26-
# TODO Implement test as things are filled out
26+
after do
27+
ENV['BUILDPACK_CACHE'] = @previous_value
2728
end
2829

29-
it 'should print the error message if an error occurs' do
30-
# TODO Implement test as things are filled out
31-
end
30+
it 'should return zero if the compile is successful' do
31+
FIXTURE = 'spec/fixtures/java'
3232

33-
private
33+
Dir.mktmpdir do |root|
34+
FileUtils.cp_r "#{FIXTURE}/.", root
3435

35-
COMPILE = File.expand_path('../../../bin/compile', __FILE__)
36-
FIXTURES_DIR = File.expand_path('../../fixtures', __FILE__)
36+
Open3.popen3("bin/compile #{root}") do |stdin, stdout, stderr, wait_thr|
37+
expect(wait_thr.value).to be_success
38+
end
39+
end
40+
end
3741

3842
end

spec/bin/detect_spec.rb

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,21 @@
1919
describe 'detect' do
2020

2121
it 'should return non-zero if the application is not Java' do
22-
Open3.popen3("#{DETECT} #{FIXTURES_DIR}/non-java") do |stdin, stdout, stderr, wait_thr|
23-
expect(stdout.read).to eq('')
24-
expect(stderr.read).to eq('')
22+
Open3.popen3("bin/detect spec/fixtures/non-java") do |stdin, stdout, stderr, wait_thr|
2523
expect(wait_thr.value).to_not be_success
2624
end
2725
end
2826

2927
it 'should return zero if the application is Java' do
30-
# TODO Implement test as things are filled out
28+
Open3.popen3("bin/detect spec/fixtures/java") do |stdin, stdout, stderr, wait_thr|
29+
expect(wait_thr.value).to be_success
30+
end
3131
end
3232

3333
it 'should print the names of participating components if the application is Java' do
34-
# TODO Implement test as things are filled out
35-
end
36-
37-
it 'should return non-zero if an error occurs' do
38-
# TODO Implement test as things are filled out
39-
end
40-
41-
it 'should print the error message if an error occurs' do
42-
# TODO Implement test as things are filled out
34+
Open3.popen3("bin/detect spec/fixtures/java") do |stdin, stdout, stderr, wait_thr|
35+
expect(stdout.read).to match(/java-openjdk-8/)
36+
end
4337
end
4438

45-
private
46-
47-
DETECT = File.expand_path('../../../bin/detect', __FILE__)
48-
FIXTURES_DIR = File.expand_path('../../fixtures', __FILE__)
49-
5039
end

0 commit comments

Comments
 (0)