Skip to content

Commit b696d54

Browse files
committed
Merge branch 'offline'
2 parents f79e04d + fb644d4 commit b696d54

49 files changed

Lines changed: 1022 additions & 1620 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
.bundle
21
.idea/tasks.xml
32
.idea/workspace.xml
43
.yardoc
4+
build/
55
coverage
66
doc
7-
out

.idea/.rakeTasks

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/dictionaries/bhale.xml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.rubocop.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
---
22
AllCops:
3+
Includes:
4+
- Rakefile
5+
- rakelib/**
36
Excludes:
4-
- vendor/**
7+
- build/**
58
ClassLength:
69
Max: 200
7-
ClassVars:
8-
Enabled: false
910
CyclomaticComplexity:
1011
Max: 10
1112
Documentation:

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
addressable (2.3.5)
4+
addressable (2.3.6)
55
ast (1.1.0)
66
codeclimate-test-reporter (0.3.0)
77
simplecov (>= 0.7.1, < 1.0.0)
@@ -17,7 +17,7 @@ GEM
1717
slop (~> 3.4, >= 3.4.5)
1818
powerpack (0.0.9)
1919
rainbow (2.0.0)
20-
rake (10.1.1)
20+
rake (10.2.0)
2121
redcarpet (3.1.1)
2222
rspec (3.0.0.beta2)
2323
rspec-core (= 3.0.0.beta2)

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,39 @@ To learn how to configure various properties of the buildpack, follow the "Confi
6666
* [Java Test Applications](https://github.com/cloudfoundry/java-test-applications)
6767
* [Java Buildpack System Tests](https://github.com/cloudfoundry/java-buildpack-system-test)
6868

69+
## Building Packages
70+
The buildpack can be packaged up so that it can uploaded to Cloud Foundry using the `cf create-buildpack` and `cf update-buildpack` commands. In order to create these packages, the rake `package` task is used.
71+
72+
### Online Package
73+
The online package is a version of the buildpack that is as minimal as possible and is configured to connect to the network for all dependencies. This package is about 50K in size. To create the online package, run:
74+
75+
```bash
76+
bundle install
77+
bundle exec rake package
78+
...
79+
Creating build/java-buildpack-cfd6b17.tar.gz
80+
```
81+
82+
### Offline Package
83+
The offline package is a version of the buildpack designed to run without access to a network. It packages the latest version of each dependency (as configured in the [`config/` directory][]) and [disables `remote_downloads`][]. This package is about 180M in size. To create the offline package, use the `OFFLINE=true` argument:
84+
85+
```bash
86+
bundle install
87+
bundle exec rake package OFFLINE=true
88+
...
89+
Creating build/java-buildpack-offline-cfd6b17.tar.gz
90+
```
91+
92+
### Package Versioning
93+
Keeping track of different versions of the buildpack can be difficult. To help with this, the rake `package` task puts a version discriminator in the name of the created package file. The default value for this discriminator is the current Git hash (e.g. `cfd6b17`). To change the version when creating a package, use the `VERSION=<VERSION>` argument:
94+
95+
```bash
96+
bundle install
97+
bundle exec rake package VERSION=2.1
98+
...
99+
Creating build/java-buildpack-2.1.tar.gz
100+
```
101+
69102
## Running Tests
70103
To run the tests, do the following:
71104

@@ -82,9 +115,11 @@ bundle exec rake
82115
## License
83116
This buildpack is released under version 2.0 of the [Apache License][].
84117

118+
[`config/` directory]: config
85119
[Apache License]: http://www.apache.org/licenses/LICENSE-2.0
86120
[Cloud Foundry]: http://www.cloudfoundry.com
87121
[contributor guidelines]: CONTRIBUTING.md
122+
[disables `remote_downloads`]: docs/extending-caches.md#configuration
88123
[GitHub's forking functionality]: https://help.github.com/articles/fork-a-repo
89124
[Grails]: http://grails.org
90125
[Groovy]: http://groovy.codehaus.org

Rakefile

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Encoding: utf-8
12
# Cloud Foundry Java Buildpack
23
# Copyright (c) 2013 the original author or authors.
34
#
@@ -13,29 +14,33 @@
1314
# See the License for the specific language governing permissions and
1415
# limitations under the License.
1516

17+
require 'rake/clean'
18+
1619
require 'rspec/core/rake_task'
1720
RSpec::Core::RakeTask.new
18-
19-
require 'yard'
20-
YARD::Rake::YardocTask.new
21+
CLOBBER << 'coverage'
2122

2223
require 'rubocop/rake_task'
2324
Rubocop::RakeTask.new
2425

25-
require 'open3'
26+
require 'yard'
27+
YARD::Rake::YardocTask.new
28+
CLEAN << '.yardoc'
29+
CLOBBER << 'doc'
30+
31+
desc 'Check that all APIs have been documented'
2632
task :check_api_doc do
27-
puts "\nChecking API documentation..."
28-
output = Open3.capture3('yard stats --list-undoc')[0]
29-
if output !~ /100.00% documented/
30-
puts "\nFailed due to undocumented public API:\n\n#{output}"
31-
exit 1
32-
else
33-
puts "\n#{output}\n"
34-
end
33+
output = `yard stats --list-undoc`
34+
abort "\nFailed due to undocumented public API:\n\n#{output}" if output !~ /100.00% documented/
3535
end
3636

37-
require 'rake/clean'
38-
CLEAN.include %w(.yardoc coverage)
39-
CLOBBER.include %w(doc pkg)
37+
$LOAD_PATH.unshift File.expand_path('..', __FILE__)
38+
require 'rakelib/dependency_cache_task'
39+
require 'rakelib/stage_buildpack_task'
40+
require 'rakelib/package_task'
41+
Package::DependencyCacheTask.new
42+
Package::StageBuildpackTask.new(Dir['bin/**/*', 'config/**/*', 'lib/**/*', 'resources/**/*']
43+
.reject { |f| File.directory? f })
44+
Package::PackageTask.new
4045

41-
task :default => [ :rubocop, :check_api_doc, :spec ]
46+
task default: %w(rubocop check_api_doc spec)

docs/extending-caches.md

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Caches
2-
Many components will want to cache large files that are downloaded for applications. The buildpack provides a cache abstraction to encapsulate this caching behavior. The cache abstraction is comprised of three cache types each with the same signature.
2+
Many components will want to cache large files that are downloaded for applications. The buildpack provides a cache abstraction to encapsulate this caching behavior. The cache abstraction is comprised of two cache types each with the same signature.
33

44
```ruby
55
# Retrieves an item from the cache. Retrieval of the item uses the following algorithm:
@@ -48,7 +48,7 @@ Caching can be configured by modifying the [`config/cache.yml`][] file in the bu
4848
| `remote_downloads` | This property can take the value `enabled` or `disabled`. <p>The default value of `enabled` means that the buildpack will check the internet connection and remember the result for the remainder of the buildpack invocation. If the internet is available, it will then be used to download files. If the internet is not available, cache will be consulted instead. <p>Alternatively, the property may be set to `disabled` which avoids the check for an internet connection, does not attempt downloads, and consults the cache instead.
4949

5050
## `JavaBuildpack::Util::Cache::DownloadCache`
51-
The [`DownloadCache`][] is the most generic of the three caches. It allows you to create a cache that persists files any that write access is available. The constructor signature looks the following:
51+
The [`DownloadCache`][] is the most generic of the two caches. It allows you to create a cache that persists files any that write access is available. The constructor signature looks the following:
5252

5353
```ruby
5454
# Creates an instance of the cache that is backed by the filesystem rooted at +cache_root+
@@ -68,19 +68,7 @@ The [`ApplicationCache`][] is a cache that persists files into the application c
6868
def initialize
6969
```
7070

71-
## `JavaBuildpack::Util::Cache::GlobalCache`
72-
The [`GlobalCache`][] is a cache that persists files into the global cache passed to all scripts. It examines `ENV['BUILDPACK_CACHE']` for the cache location and configures itself accordingly.
73-
74-
```ruby
75-
# Creates an instance that is configured to use the global cache. The global cache location is defined by the
76-
# +BUILDPACK_CACHE+ environment variable
77-
#
78-
# @raise if the +BUILDPACK_CACHE+ environment variable is +nil+
79-
def initialize
80-
```
81-
8271
[`ApplicationCache`]: ../lib/java_buildpack/util/cache/application_cache.rb
8372
[`config/cache.yml`]: ../config/cache.yml
8473
[`DownloadCache`]: ../lib/java_buildpack/util/cache/download_cache.rb
85-
[`GlobalCache`]: ../lib/java_buildpack/util/cache/global_cache.rb
8674
[Configuration and Extension]: ../README.md#configuration-and-extension

java-buildpack.iml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,12 +263,13 @@
263263
<sourceFolder url="file://$MODULE_DIR$/spec/java_buildpack" isTestSource="true" />
264264
<excludeFolder url="file://$MODULE_DIR$/.idea" />
265265
<excludeFolder url="file://$MODULE_DIR$/.yardoc" />
266+
<excludeFolder url="file://$MODULE_DIR$/build" />
266267
<excludeFolder url="file://$MODULE_DIR$/coverage" />
267268
<excludeFolder url="file://$MODULE_DIR$/doc" />
268269
</content>
269270
<orderEntry type="jdk" jdkName="rbenv: 1.9.3-p545" jdkType="RUBY_SDK" />
270271
<orderEntry type="sourceFolder" forTests="false" />
271-
<orderEntry type="library" scope="PROVIDED" name="addressable (v2.3.5, rbenv: 1.9.3-p545) [gem]" level="application" />
272+
<orderEntry type="library" scope="PROVIDED" name="addressable (v2.3.6, rbenv: 1.9.3-p545) [gem]" level="application" />
272273
<orderEntry type="library" scope="PROVIDED" name="ast (v1.1.0, rbenv: 1.9.3-p545) [gem]" level="application" />
273274
<orderEntry type="library" scope="PROVIDED" name="bundler (v1.5.3, rbenv: 1.9.3-p545) [gem]" level="application" />
274275
<orderEntry type="library" scope="PROVIDED" name="codeclimate-test-reporter (v0.3.0, rbenv: 1.9.3-p545) [gem]" level="application" />
@@ -281,7 +282,7 @@
281282
<orderEntry type="library" scope="PROVIDED" name="parser (v2.1.7, rbenv: 1.9.3-p545) [gem]" level="application" />
282283
<orderEntry type="library" scope="PROVIDED" name="powerpack (v0.0.9, rbenv: 1.9.3-p545) [gem]" level="application" />
283284
<orderEntry type="library" scope="PROVIDED" name="rainbow (v2.0.0, rbenv: 1.9.3-p545) [gem]" level="application" />
284-
<orderEntry type="library" scope="PROVIDED" name="rake (v10.1.1, rbenv: 1.9.3-p545) [gem]" level="application" />
285+
<orderEntry type="library" scope="PROVIDED" name="rake (v10.2.0, rbenv: 1.9.3-p545) [gem]" level="application" />
285286
<orderEntry type="library" scope="PROVIDED" name="redcarpet (v3.1.1, rbenv: 1.9.3-p545) [gem]" level="application" />
286287
<orderEntry type="library" scope="PROVIDED" name="rspec (v3.0.0.beta2, rbenv: 1.9.3-p545) [gem]" level="application" />
287288
<orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.0.0.beta2, rbenv: 1.9.3-p545) [gem]" level="application" />

lib/java_buildpack/buildpack.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,14 @@ def release
9393

9494
private
9595

96-
DEFAULT_BUILDPACK_MESSAGE = '-----> Java Buildpack source: system'.freeze
96+
DEFAULT_BUILDPACK_MESSAGE = '-----> Java Buildpack source: unknown'.freeze
9797

9898
GIT_DIR = Pathname.new(__FILE__).dirname + '../../.git'
9999

100100
LOAD_ROOT = Pathname.new(__FILE__).dirname + '..'
101101

102102
def initialize(app_dir, application)
103-
@logger = Logging::LoggerFactory.get_logger Buildpack
103+
@logger = Logging::LoggerFactory.instance.get_logger Buildpack
104104

105105
log_environment_variables
106106

@@ -125,7 +125,7 @@ def component_detection(components)
125125

126126
def diagnose_git_info(print)
127127
if system("git --git-dir=#{GIT_DIR} status 2>/dev/null 1>/dev/null")
128-
remote_url = diagnose_remotes
128+
remote_url = diagnose_remote
129129
head_commit_sha = diagnose_head_commit
130130
puts "-----> Java Buildpack source: #{remote_url}##{head_commit_sha}" if print
131131
else
@@ -135,17 +135,17 @@ def diagnose_git_info(print)
135135
end
136136

137137
def diagnose_head_commit
138-
git 'log HEAD^!', 'git HEAD commit: %s'
138+
git 'rev-parse --short HEAD', 'git HEAD commit: %s'
139139
end
140140

141-
def diagnose_remotes
142-
git 'remote -v', 'git remotes: %s'
141+
def diagnose_remote
142+
git 'config --get remote.origin.url', 'git remote: %s'
143143
end
144144

145145
def git(command, message)
146-
result = `git --git-dir=#{GIT_DIR} #{command}`
146+
result = `git --git-dir=#{GIT_DIR} #{command}`.chomp
147147
@logger.debug { message % result }
148-
result.split(' ')[1]
148+
result
149149
end
150150

151151
def instantiate(components, additional_libraries, application, java_home, java_opts, root)
@@ -201,7 +201,7 @@ class << self
201201
def with_buildpack(app_dir, message)
202202
app_dir = Pathname.new(File.expand_path(app_dir))
203203
application = Component::Application.new(app_dir)
204-
Logging::LoggerFactory.setup app_dir
204+
Logging::LoggerFactory.instance.setup app_dir
205205

206206
yield new(app_dir, application) if block_given?
207207
rescue => e
@@ -211,7 +211,7 @@ def with_buildpack(app_dir, message)
211211
private
212212

213213
def handle_error(e, message)
214-
logger = Logging::LoggerFactory.get_logger Buildpack
214+
logger = Logging::LoggerFactory.instance.get_logger Buildpack
215215

216216
logger.error { message % e.inspect }
217217
logger.debug { "Exception #{e.inspect} backtrace:\n#{e.backtrace.join("\n")}" }

0 commit comments

Comments
 (0)