@@ -19,7 +19,7 @@ def _run_android_lint(
1919 ctx ,
2020 android_lint ,
2121 module_name ,
22- output ,
22+ xml_output ,
2323 html_output ,
2424 srcs ,
2525 deps ,
@@ -44,7 +44,7 @@ def _run_android_lint(
4444 ctx: The target context
4545 android_lint: The Android Lint binary to use
4646 module_name: The name of the module
47- output : The output file
47+ xml_output : The xml_output file
4848 srcs: The source files
4949 deps: Depset of aars and jars to include on the classpath
5050 resource_files: The Android resource files
@@ -64,7 +64,7 @@ def _run_android_lint(
6464 android_lint_skip_bytecode_verifier: Disables bytecode verification
6565 """
6666 inputs = []
67- outputs = [output , html_output ]
67+ outputs = []
6868
6969 args = ctx .actions .args ()
7070 args .set_param_file_format ("multiline" )
@@ -115,16 +115,14 @@ def _run_android_lint(
115115 if android_lint_enable_check_dependencies :
116116 args .add ("--enable-check-dependencies" )
117117
118- # Declare the output file
119- args .add ("--output" , output )
120- outputs .append (output )
121-
122- args .add ("--html-output" , html_output )
123- outputs .append (html_output )
124-
125- label = ctx .attr .android_home .label
126- if ctx .attr .android_home :
127- args .add ("--android_home" , label .workspace_root )
118+ if xml_output != None :
119+ args .add ("--xml-output" , xml_output )
120+ outputs .append (xml_output )
121+ if html_output != None :
122+ args .add ("--html-output" , html_output )
123+ outputs .append (html_output )
124+ if len (outputs ) == 0 :
125+ fail ("Lint cannot have no outputs!" )
128126
129127 ctx .actions .run (
130128 mnemonic = "AndroidLint" ,
@@ -171,7 +169,7 @@ def process_android_lint_issues(ctx, regenerate):
171169 regenerate: Whether to regenerate the baseline files
172170
173171 Returns:
174- A struct containing the output file and the providers
172+ A struct containing the output files and the providers
175173 """
176174
177175 # Append the Android manifest file. Lint requires that the input manifest files be named
@@ -205,13 +203,20 @@ def process_android_lint_issues(ctx, regenerate):
205203 _utils .list_or_depset_to_list (_utils .get_android_lint_toolchain (ctx ).android_lint_config .files ),
206204 )
207205
208- output = ctx .actions .declare_file ("{}.xml" .format (ctx .label .name ))
209- html_output = ctx .actions .declare_file ("{}.html" .format (ctx .label .name ))
206+ baseline = getattr (ctx .file , "baseline" , None )
207+ xml_output = None
208+ html_output = None
209+ for output_format in ctx .attr .output_formats :
210+ if output_format == "xml" :
211+ xml_output = ctx .actions .declare_file ("{}.xml" .format (ctx .label .name ))
212+ if output_format == "html" :
213+ html_output = ctx .actions .declare_file ("{}.html" .format (ctx .label .name ))
214+
210215 _run_android_lint (
211216 ctx ,
212217 android_lint = _utils .only (_utils .list_or_depset_to_list (_utils .get_android_lint_toolchain (ctx ).android_lint .files )),
213218 module_name = _get_module_name (ctx ),
214- output = output ,
219+ xml_output = xml_output ,
215220 html_output = html_output ,
216221 srcs = ctx .files .srcs ,
217222 deps = depset (transitive = deps ),
@@ -220,7 +225,7 @@ def process_android_lint_issues(ctx, regenerate):
220225 compile_sdk_version = _utils .get_android_lint_toolchain (ctx ).compile_sdk_version ,
221226 java_language_level = _utils .get_android_lint_toolchain (ctx ).java_language_level ,
222227 kotlin_language_level = _utils .get_android_lint_toolchain (ctx ).kotlin_language_level ,
223- baseline = getattr ( ctx . file , " baseline" , None ) ,
228+ baseline = baseline ,
224229 config = config ,
225230 warnings_as_errors = ctx .attr .warnings_as_errors ,
226231 custom_rules = ctx .files .custom_rules ,
@@ -233,10 +238,14 @@ def process_android_lint_issues(ctx, regenerate):
233238 )
234239
235240 return struct (
236- output = output ,
241+ baseline = baseline ,
242+ xml_output = xml_output ,
243+ html_output = html_output ,
237244 providers = [
238245 _AndroidLintResultsInfo (
239- output = output ,
246+ baseline = baseline ,
247+ xml_output = xml_output ,
248+ html_output = html_output ,
240249 ),
241250 ],
242251 )
0 commit comments