Skip to content

Commit adc7428

Browse files
committed
Merge branch '478-directories-ending-in-jar'
2 parents bac2890 + e5c659f commit adc7428

File tree

6 files changed

+25
-4
lines changed

6 files changed

+25
-4
lines changed

lib/java_buildpack/framework/jrebel_agent.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ def jrebel_configured?(root_path)
5959
end
6060

6161
def jars_with_jrebel_configured?(root_path)
62-
(root_path + '**/*.jar').glob.any? { |jar| !`unzip -l "#{jar}" | grep "rebel-remote\\.xml$"`.strip.empty? }
62+
(root_path + '**/*.jar')
63+
.glob.reject(&:directory?)
64+
.any? { |jar| !`unzip -l "#{jar}" | grep "rebel-remote\\.xml$"`.strip.empty? }
6365
end
6466

6567
def lib_name

lib/java_buildpack/jre/open_jdk_like_memory_calculator.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ def supports?
7171
def actual_class_count(root)
7272
(root + '**/*.class').glob.count +
7373
(root + '**/*.groovy').glob.count +
74-
(root + '**/*.jar').glob(File::FNM_DOTMATCH).inject(0) { |a, e| a + archive_class_count(e) }
74+
(root + '**/*.jar').glob(File::FNM_DOTMATCH).reject(&:directory?)
75+
.inject(0) { |a, e| a + archive_class_count(e) }
7576
end
7677

7778
def archive_class_count(archive)

spec/fixtures/framework_jrebel_jar_directory/dependency.jar/.gitkeep

Whitespace-only changes.

spec/fixtures/jre_memory_calculator_jar_directory/dependency.jar/.gitkeep

Whitespace-only changes.

spec/java_buildpack/framework/jrebel_agent_spec.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,13 @@
4444

4545
it 'does not detect when not enabled',
4646
app_fixture: 'framework_jrebel_app_simple' do
47+
4748
expect(component.detect).to be_nil
4849
end
4950
end
5051

5152
it 'downloads the JRebel JAR and the native agent',
52-
app_fixture: 'framework_jrebel_app_simple',
53+
app_fixture: 'framework_jrebel_app_simple',
5354
cache_fixture: 'stub-jrebel-archive.zip' do
5455

5556
component.compile
@@ -59,7 +60,7 @@
5960
end
6061

6162
it 'adds correct arguments to JAVA_OPTS',
62-
app_fixture: 'framework_jrebel_app_simple',
63+
app_fixture: 'framework_jrebel_app_simple',
6364
cache_fixture: 'stub-jrebel-archive.zip' do
6465

6566
allow(component).to receive(:architecture).and_return('x86_64')
@@ -71,4 +72,12 @@
7172
expect(java_opts).to include('-Drebel.cloud.platform=cloudfoundry/java-buildpack')
7273
end
7374

75+
it 'does not throw an error when a directory ends in .jar',
76+
app_fixture: 'framework_jrebel_jar_directory' do
77+
78+
expect_any_instance_of(described_class).not_to receive(:`).with(start_with("unzip -l #{app_dir + 'directory.jar'}"))
79+
80+
component.detect
81+
end
82+
7483
end

spec/java_buildpack/jre/open_jdk_like_memory_calculator_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,13 @@
8888
'Configuration: $CALCULATED_MEMORY && JAVA_OPTS="$JAVA_OPTS $CALCULATED_MEMORY"')
8989
end
9090

91+
it 'does not throw an error when a directory ends in .jar',
92+
app_fixture: 'jre_memory_calculator_jar_directory',
93+
cache_fixture: 'stub-memory-calculator.tar.gz' do
94+
95+
expect_any_instance_of(described_class).not_to receive(:`).with(start_with("unzip -l #{app_dir + 'directory.jar'}"))
96+
97+
component.compile
98+
end
99+
91100
end

0 commit comments

Comments
 (0)