Skip to content

Commit fbf2cf1

Browse files
Handle empty source jars
1 parent 09ef011 commit fbf2cf1

File tree

2 files changed

+8
-2
lines changed
  • examples/bazel-example/src/main/java/srcjar_example
  • scip-java/src/main/resources/scip-java

2 files changed

+8
-2
lines changed

examples/bazel-example/src/main/java/srcjar_example/BUILD

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,18 @@ genrule(
44
cmd = "echo 'package com.testing; public class Bar {};' > Bar.java && jar cf $(@) Bar.java",
55
)
66

7+
genrule(
8+
name = "empty-srcjar",
9+
outs = ["empty.srcjar"],
10+
cmd = "touch test.txt && zip $(@) test.txt && zip -d $(@) test.txt",
11+
)
12+
713
java_library(
814
name = "testing",
915
srcs = [
1016
"Foo.java",
1117
":generated-srcjar",
18+
":empty-srcjar"
1219
],
1320
)
1421

@@ -19,4 +26,3 @@ java_library(
1926
":generated-srcjar",
2027
],
2128
)
22-

scip-java/src/main/resources/scip-java/scip_java.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def _scip_java(target, ctx):
7878
outputs = [dir],
7979
mnemonic = "ExtractSourceJars",
8080
command = """
81-
unzip {input_file} -d {output_dir}
81+
[ "$(unzip -q -l {input_file} | wc -l)" -eq 0 ] || unzip {input_file} -d {output_dir}
8282
""".format(
8383
output_dir = dir.path,
8484
input_file = source_jar.path,

0 commit comments

Comments
 (0)