Skip to content

Commit 67bb6f4

Browse files
author
Glyn Normington
committed
Avoid directories in Groovy detection
Directories such as: grapes/org.codehaus.groovy caused a failure in the Groovy detect logic, so filter out directories. Add a test to verify the correct behaviour. [#53781773]
1 parent 0107755 commit 67bb6f4

3 files changed

Lines changed: 11 additions & 1 deletion

File tree

lib/java_buildpack/container/groovy.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def self.find_groovy(app_dir, configuration)
128128

129129
def self.groovy_files(root)
130130
root_directory = Pathname.new(root)
131-
Dir[File.join root, GROOVY_FILE_PATTERN] .map { |file| Pathname.new(file).relative_path_from(root_directory).to_s }
131+
Dir[File.join root, GROOVY_FILE_PATTERN] .reject{ |file| File.directory? file } .map { |file| Pathname.new(file).relative_path_from(root_directory).to_s }
132132
end
133133

134134
def groovy_home

spec/fixtures/dot_groovy/x/y.groovy/.gitignore

Whitespace-only changes.

spec/java_buildpack/container/groovy_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ module JavaBuildpack::Container
4141
expect(detected).to be_nil
4242
end
4343

44+
it 'should not detect a .groovy directory' do
45+
JavaBuildpack::Repository::ConfiguredItem.stub(:find_item) { |&block| block.call(VERSION) if block }
46+
.and_return(DETAILS)
47+
detected = Groovy.new(
48+
:app_dir => 'spec/fixtures/dot_groovy',
49+
:configuration => {}).detect
50+
51+
expect(detected).to be_nil
52+
end
53+
4454
it 'should detect a single Groovy file' do
4555
JavaBuildpack::Repository::ConfiguredItem.stub(:find_item) { |&block| block.call(VERSION) if block }
4656
.and_return(DETAILS)

0 commit comments

Comments
 (0)