Skip to content

Commit 714a465

Browse files
committed
Compile script
Previously, the buildpack did not meet the contractual obligations for the compile phase of the buildpack lifecycle. This change adds a bin/compile shell script which delegates to a ruby class internally. This class currently does nothing, but will need to delegate to buildpack components in the future. [#49321271]
1 parent 56b50de commit 714a465

File tree

8 files changed

+172
-3
lines changed

8 files changed

+172
-3
lines changed

bin/compile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env ruby
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+
$:.unshift File.expand_path("../../lib", __FILE__)
18+
require 'java_buildpack'
19+
20+
build_dir = ARGV[0]
21+
cache_dir = ARGV[1]
22+
23+
begin
24+
JavaBuildpack::Compile.new(build_dir, cache_dir).run
25+
rescue => e
26+
abort e.message
27+
end
28+

bin/detect

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,14 @@ require 'java_buildpack'
1919

2020
build_dir = ARGV[0]
2121

22-
JavaBuildpack::Detect.new(build_dir).run
22+
begin
23+
components = JavaBuildpack::Detect.new(build_dir).run
24+
unless components.empty?
25+
puts components
26+
else
27+
abort
28+
end
29+
rescue => e
30+
abort e.message
31+
end
32+

lib/java-buildpack/compile.rb

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Cloud Foundry Java Buildpack
2+
# Copyright (c) 2013 the original author or authors.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
# Encapsulates the compilation functionality in the Java buildpack
17+
class JavaBuildpack::Compile
18+
19+
# Creates a new instance, passing in the application directory used during compilation
20+
#
21+
# @param [String] app_dir The application directory used during compilation
22+
# @param [String] app_cache_dir The application cache directory used during compilation
23+
def initialize(app_dir, app_cache_dir)
24+
25+
end
26+
27+
# The execution entry point for detection. This method is responsible for identifying all of the components that are
28+
# that which to participate in the buildpack and returning their names.
29+
#
30+
# @return [void]
31+
def run
32+
33+
end
34+
35+
end

lib/java-buildpack/detect.rb

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

16+
# Encapsulates the detection functionality in the Java buildpack
1617
class JavaBuildpack::Detect
1718

19+
# Creates a new instance, passing in the application directory used during detection
20+
#
21+
# @param [String] app_dir The application directory used during detection
1822
def initialize(app_dir)
1923

2024
end
2125

26+
# The execution entry point for detection. This method is responsible for identifying all of the components that are
27+
# that which to participate in the buildpack and returning their names.
28+
#
29+
# @return [Array<String>] the names of components that wish to participate in the buildpack
2230
def run
23-
31+
[]
2432
end
2533

2634
end

lib/java_buildpack.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
module JavaBuildpack
1818
end
1919

20+
require 'java-buildpack/compile'
2021
require 'java-buildpack/detect'
21-
#require 'java-buildpack/compile'
2222
#require 'java-buildpack/release'

spec/bin/compile_spec.rb

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Git Pivotal Tracker Integration
2+
# Copyright (c) 2013 the original author or authors.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
require 'spec_helper'
17+
require 'open3'
18+
19+
describe 'compile' do
20+
21+
it 'should return zero if the compile is successful' do
22+
# TODO Implement test as things are filled out
23+
end
24+
25+
it 'should return non-zero if an error occurs' do
26+
# TODO Implement test as things are filled out
27+
end
28+
29+
it 'should print the error message if an error occurs' do
30+
# TODO Implement test as things are filled out
31+
end
32+
33+
private
34+
35+
COMPILE = File.expand_path('../../../bin/compile', __FILE__)
36+
FIXTURES_DIR = File.expand_path('../../fixtures', __FILE__)
37+
38+
end

spec/bin/detect_spec.rb

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Git Pivotal Tracker Integration
2+
# Copyright (c) 2013 the original author or authors.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
require 'spec_helper'
17+
require 'open3'
18+
19+
describe 'detect' do
20+
21+
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('')
25+
expect(wait_thr.value).to_not be_success
26+
end
27+
end
28+
29+
it 'should return zero if the application is Java' do
30+
# TODO Implement test as things are filled out
31+
end
32+
33+
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
43+
end
44+
45+
private
46+
47+
DETECT = File.expand_path('../../../bin/detect', __FILE__)
48+
FIXTURES_DIR = File.expand_path('../../fixtures', __FILE__)
49+
50+
end

spec/fixtures/non-java/test.js

Whitespace-only changes.

0 commit comments

Comments
 (0)