@@ -57,10 +57,36 @@ def _scip_java(target, ctx):
57
57
annotations = info .annotation_processing
58
58
59
59
source_files = []
60
+ source_jars = []
60
61
for src in ctx .rule .files .srcs :
61
- source_files .append (src .path )
62
+ if src .path .endswith (".java" ):
63
+ source_files .append (src .path )
64
+ elif src .path .endswith (".srcjar" ):
65
+ source_jars .append (src )
66
+
62
67
if len (source_files ) == 0 :
63
68
return None
69
+
70
+ output_dir = []
71
+
72
+ for source_jar in source_jars :
73
+ dir = ctx .actions .declare_directory ("extracted_" + source_jar .basename )
74
+ output_dir .append (dir )
75
+
76
+ ctx .actions .run_shell (
77
+ inputs = javac_action .inputs ,
78
+ outputs = [dir ],
79
+ mnemonic = "ExtractSourceJars" ,
80
+ command = """
81
+ unzip {input_file} -d {output_dir}
82
+ """ .format (
83
+ output_dir = dir .path ,
84
+ input_file = source_jar .path ,
85
+ ),
86
+ progress_message = "Extracting source jar {jar}" .format (jar = source_jar .path ),
87
+ )
88
+
89
+ source_files .append (dir .path )
64
90
65
91
classpath = [j .path for j in compilation .compilation_classpath .to_list ()]
66
92
bootclasspath = [j .path for j in compilation .boot_classpath ]
@@ -73,11 +99,16 @@ def _scip_java(target, ctx):
73
99
74
100
launcher_javac_flags = []
75
101
compiler_javac_flags = []
76
- for value in compilation .javac_options :
77
- if value .startswith ("-J" ):
78
- launcher_javac_flags .append (value )
79
- else :
80
- compiler_javac_flags .append (value )
102
+
103
+ for value in compilation .javac_options_list :
104
+ # NOTE(Anton): for some bizarre reason I see empty string starting the list of
105
+ # javac options - which then gets propagated into the JSON config, and ends up
106
+ # crashing the actual javac invokation.
107
+ if value != "" :
108
+ if value .startswith ("-J" ):
109
+ launcher_javac_flags .append (value )
110
+ else :
111
+ compiler_javac_flags .append (value )
81
112
82
113
build_config = struct (** {
83
114
"javaHome" : ctx .var ["java_home" ],
@@ -100,6 +131,7 @@ def _scip_java(target, ctx):
100
131
)
101
132
102
133
deps = [javac_action .inputs , annotations .processor_classpath ]
134
+
103
135
ctx .actions .run_shell (
104
136
command = "\" {}\" index --no-cleanup --index-semanticdb.allow-empty-index --cwd \" {}\" --targetroot {} --scip-config \" {}\" --output \" {}\" " .format (
105
137
ctx .var ["scip_java_binary" ],
@@ -113,7 +145,7 @@ def _scip_java(target, ctx):
113
145
"NO_PROGRESS_BAR" : "true" ,
114
146
},
115
147
mnemonic = "ScipJavaIndex" ,
116
- inputs = depset ([build_config_path ], transitive = deps ),
148
+ inputs = depset ([build_config_path ] + output_dir , transitive = deps ),
117
149
outputs = [scip_output , targetroot ],
118
150
)
119
151
0 commit comments