11"""Generate AXT android archive (aar)."""
22
33load ("//build_extensions/maven:combine_jars.bzl" , "combine_jars" )
4- load ("//build_extensions/maven:maven_info.bzl" , "MavenFilesInfo" , "MavenInfo" )
4+ load ("//build_extensions/maven:maven_info.bzl" , "MavenFilesInfo" , "MavenInfo" , "collect_maven_apk_info" )
55
66def _axt_maven_apk_impl (ctx ):
77 # produce src jar
8- # hack - exclude source jars from external maven artifacts
9- # TODO(b/283992063): use an aspect to gather this info
10- axt_jars = [jar for jar in ctx .attr .included_dep [JavaInfo ].transitive_source_jars .to_list () if "maven.org" not in jar .path ]
118 combine_jars (
129 ctx = ctx ,
13- input_jars_deps = axt_jars ,
10+ input_jars_deps = ctx . attr . included_dep [ MavenInfo ]. transitive_included_src_jars ,
1411 output = ctx .outputs .src_jar ,
1512 )
1613
17- maven_info = MavenInfo (
18- artifact = ctx .attr .artifact ,
19- is_compileOnly = False ,
20- is_shaded = False ,
21- transitive_included_runtime_jars = depset (),
22- transitive_included_src_jars = depset (),
23- transitive_maven_direct_deps = depset (ctx .attr .maven_deps ),
24- )
25-
26- return [maven_info , MavenFilesInfo (runtime = ctx .attr .included_dep [ApkInfo ].signed_apk , src_jar = ctx .outputs .src_jar , validation = None )]
14+ return [
15+ ctx .attr .included_dep [MavenInfo ],
16+ MavenFilesInfo (runtime = ctx .attr .included_dep [ApkInfo ].signed_apk , src_jar = ctx .outputs .src_jar , validation = None ),
17+ ]
2718
2819axt_maven_apk = rule (
2920 implementation = _axt_maven_apk_impl ,
@@ -32,13 +23,7 @@ axt_maven_apk = rule(
3223 doc = "The android_binary to publish" ,
3324 mandatory = True ,
3425 providers = [JavaInfo , ApkInfo ],
35- ),
36- "artifact" : attr .string (
37- doc = "the maven coordinates of the apk" ,
38- mandatory = True ,
39- ),
40- "maven_deps" : attr .string_list (
41- doc = "the maven coordinates of the runtime dependencies of the apk" ,
26+ aspects = [collect_maven_apk_info ],
4227 ),
4328 "_combine_jars_java" : attr .label (
4429 executable = True ,
0 commit comments