Skip to content

Commit 96a6cf1

Browse files
committed
Merge 59473228-relative-paths to master
[Completes #59473228]
2 parents b890103 + b61601c commit 96a6cf1

134 files changed

Lines changed: 3987 additions & 4371 deletions

File tree

Some content is hidden

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

.idea/copyright/Apache_License__Version_2_0.xml

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

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

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

.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: 3 additions & 2 deletions
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: 39 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ GEM
99
safe_yaml (~> 0.9.0)
1010
debugger-ruby_core_source (1.2.4)
1111
diff-lcs (1.2.5)
12-
docile (1.1.0)
12+
docile (1.1.1)
1313
multi_json (1.8.2)
1414
parser (2.0.0)
1515
ast (~> 1.1)

java-buildpack.iml

Lines changed: 2 additions & 2 deletions
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" />
@@ -20,7 +20,7 @@
2020
<orderEntry type="library" scope="PROVIDED" name="crack (v0.4.1, rbenv: 1.9.3-p448) [gem]" level="application" />
2121
<orderEntry type="library" scope="PROVIDED" name="debugger-ruby_core_source (v1.2.4, rbenv: 1.9.3-p448) [gem]" level="application" />
2222
<orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.2.5, rbenv: 1.9.3-p448) [gem]" level="application" />
23-
<orderEntry type="library" scope="PROVIDED" name="docile (v1.1.0, rbenv: 1.9.3-p448) [gem]" level="application" />
23+
<orderEntry type="library" scope="PROVIDED" name="docile (v1.1.1, rbenv: 1.9.3-p448) [gem]" level="application" />
2424
<orderEntry type="library" scope="PROVIDED" name="multi_json (v1.8.2, rbenv: 1.9.3-p448) [gem]" level="application" />
2525
<orderEntry type="library" scope="PROVIDED" name="parser (v2.0.0, rbenv: 1.9.3-p448) [gem]" level="application" />
2626
<orderEntry type="library" scope="PROVIDED" name="powerpack (v0.0.9, rbenv: 1.9.3-p448) [gem]" level="application" />

lib/java_buildpack/application.rb

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

1717
require 'java_buildpack'
18-
require 'pathname'
19-
20-
module JavaBuildpack
21-
22-
# An abstraction around the user's application. This is intended to hide the exact structure of the +app_dir+ from
23-
# components. Instead, components should use this abstraction to examine the bits of the filesystem that are specific
24-
# to it, and the application itself.
25-
class Application
26-
27-
# Creates an instance of the application abstraction.
28-
def initialize(app_dir)
29-
@root = Pathname.new(app_dir)
30-
31-
@initial_contents = []
32-
@root.find { |pathname| @initial_contents << pathname }
33-
end
34-
35-
# Returns a child with the specified relative path
36-
#
37-
# @param [String] relative_path the path to the child, relative to the application
38-
# @return [Pathname] the path to the child
39-
def child(relative_path)
40-
child = @root + relative_path
41-
child if @initial_contents.include?(child) || !child.exist?
42-
end
43-
44-
# Returns the children of the application (files and subdirectories, not recursive) as an array of +Pathname+
45-
# objects. Does not include any files created by other components.
46-
#
47-
# @return [Array<Pathname>] the children of the application
48-
# @see Pathname
49-
def children
50-
@root.children & @initial_contents
51-
end
52-
53-
# Returns the path to a directory that can be used by the component. The
54-
# return value of this method should be considered opaque and subject to
55-
# change.
56-
#
57-
# @param [String] identifier an identifier for the component
58-
# @return [Pathname] the path to the directory
59-
def component_directory(identifier)
60-
@root + ".#{identifier.downcase}"
61-
end
62-
63-
# Returns a path relative to the application root
64-
#
65-
# @param [Pathname] other the other path
66-
# @return [Patname] the relative path
67-
def relative_path_to(other)
68-
other.relative_path_from(@root)
69-
end
70-
71-
end
7218

19+
# A module encapsulating the application abstraction for the Java buildpack
20+
module JavaBuildpack::Application
7321
end
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Encoding: utf-8
2+
# Cloud Foundry Java Buildpack
3+
# Copyright 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 'fileutils'
18+
require 'java_buildpack/application'
19+
require 'pathname'
20+
21+
module JavaBuildpack::Application
22+
23+
# An abstraction encapsulating the additional libraries attached to an application
24+
class AdditionalLibraries < Pathname
25+
26+
# Creates an instance of the +JAVA_HOME+ abstraction.
27+
#
28+
# @param [Pathname] root the root directory of the application
29+
def initialize(root)
30+
@root = root
31+
@additional_paths = []
32+
@additional_libraries = @root + LIB_DIRECTORY
33+
FileUtils.mkdir_p @additional_libraries
34+
35+
super(@additional_libraries)
36+
end
37+
38+
# Add an additional path to the additional libraries collection
39+
#
40+
# @param [Pathname] path the path to add
41+
# @return [AdditionalLibraries] self to facilitate chaining
42+
def add(path)
43+
@additional_paths << path
44+
self
45+
end
46+
47+
# Returns the contents of the collection as a classpath formatted as +-cp <value1>:<value2>+
48+
#
49+
# @return [String] the contents of the collection as a classpath
50+
def as_classpath
51+
qualified_paths = paths.map { |path| qualify_path path }
52+
53+
"-cp #{qualified_paths.join ':'}"
54+
end
55+
56+
# Symlink the contents of the collection to a destination directory.
57+
#
58+
# @param [Pathname] destination the destination to link to
59+
def link_to(destination)
60+
FileUtils.mkdir_p destination
61+
paths.each { |path| (destination + path.basename).make_symlink(path.relative_path_from(destination)) }
62+
end
63+
64+
# The paths to the additional libraries
65+
#
66+
# @return [Array<Pathname>] the paths to the additional libraries
67+
def paths
68+
paths = []
69+
paths.concat @additional_paths
70+
paths.concat @additional_libraries.children
71+
.select { |child| child.extname == '.jar' }
72+
73+
paths.sort
74+
end
75+
76+
private
77+
78+
LIB_DIRECTORY = '.additional-libraries'.freeze
79+
80+
def qualify_path(path)
81+
"$PWD/#{path.relative_path_from @root}"
82+
end
83+
84+
end
85+
86+
end

0 commit comments

Comments
 (0)