File tree 3 files changed +24
-2
lines changed
examples/bazel-example/src/main/java/srcjar_example
scip-java/src/main/resources/scip-java
3 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -4,10 +4,25 @@ genrule(
4
4
cmd = "echo 'package com.testing; public class Bar {};' > Bar.java && jar cf $(@) Bar.java" ,
5
5
)
6
6
7
+ genrule (
8
+ name = "empty-srcjar" ,
9
+ outs = ["empty.srcjar" ],
10
+ cmd = "touch test.txt && zip $(@) test.txt && zip -d $(@) test.txt" ,
11
+ )
12
+
7
13
java_library (
8
14
name = "testing" ,
9
15
srcs = [
10
16
"Foo.java" ,
11
17
":generated-srcjar" ,
18
+ ":empty-srcjar"
19
+ ],
20
+ )
21
+
22
+ java_library (
23
+ name = "other_library" ,
24
+ srcs = [
25
+ "Baz.java" , # create a new file in source at test/Baz.java, alongside test/Foo.java
26
+ ":generated-srcjar" ,
12
27
],
13
28
)
Original file line number Diff line number Diff line change
1
+ package com .testing ;
2
+
3
+ public class Baz {
4
+ public Bar baz (Bar value ) {
5
+ return value ;
6
+ }
7
+ }
Original file line number Diff line number Diff line change @@ -70,15 +70,15 @@ def _scip_java(target, ctx):
70
70
output_dir = []
71
71
72
72
for source_jar in source_jars :
73
- dir = ctx .actions .declare_directory (" extracted_srcjar/" + source_jar .short_path )
73
+ dir = ctx .actions .declare_directory (ctx . label . name + "/ extracted_srcjar/" + source_jar .short_path )
74
74
output_dir .append (dir )
75
75
76
76
ctx .actions .run_shell (
77
77
inputs = javac_action .inputs ,
78
78
outputs = [dir ],
79
79
mnemonic = "ExtractSourceJars" ,
80
80
command = """
81
- unzip {input_file} -d {output_dir}
81
+ [ "$(unzip -q -l {input_file} | wc -l)" -eq 0 ] || unzip {input_file} -d {output_dir}
82
82
""" .format (
83
83
output_dir = dir .path ,
84
84
input_file = source_jar .path ,
You can’t perform that action at this time.
0 commit comments