@@ -29,35 +29,56 @@ def _collect_associates(ctx, toolchains, associate):
29
29
"""Collects the associate jars from the provided dependency and returns
30
30
them as a depset.
31
31
32
- There are two outcomes for this marco:
33
- 1. When `experimental_strict_associate_dependencies` is enabled and the tag override has not been provided, only the
34
- direct java_output compile jars will be collected for each associate target.
35
- 2. When `experimental_strict_associate_dependencies` is disabled, the complete transitive set of compile jars will
32
+ There are three outcomes for this marco:
33
+ 1. When `experimental_remove_private_classes_in_abi_jars` is enabled and the tag override has not been provided, only the
34
+ direct java_output CLASS jars will be collected for each associate target. Due to the stripping of internal and private
35
+ symbols from the compile jar, class jar is the only one that will contain the internal symbols an associate has access to.
36
+ 2. When `experimental_strict_associate_dependencies` is enabled and the tag override has not been provided, only the
37
+ direct java_output COMPILE jars will be collected for each associate target.
38
+ 3. When `experimental_strict_associate_dependencies` is disabled, the complete transitive set of compile jars will
36
39
be collected for each assoicate target.
37
40
"""
38
41
jars_depset = None
39
- if (toolchains .kt .experimental_strict_associate_dependencies and
40
- "kt_experimental_strict_associate_dependencies_incompatible" not in ctx .attr .tags ):
42
+ abi_jars_set = _sets .new ()
43
+ if (not "kt_remove_private_classes_in_abi_plugin_incompatible" in ctx .attr .tags and
44
+ toolchains .kt .experimental_remove_private_classes_in_abi_jars ):
45
+ jars_depset = depset (direct = [a .class_jar for a in associate [JavaInfo ].java_outputs ])
46
+ _sets .add_all (abi_jars_set , [a .compile_jar for a in associate [JavaInfo ].java_outputs ])
47
+ elif (toolchains .kt .experimental_strict_associate_dependencies and
48
+ "kt_experimental_strict_associate_dependencies_incompatible" not in ctx .attr .tags ):
41
49
jars_depset = depset (direct = [a .compile_jar for a in associate [JavaInfo ].java_outputs ])
42
50
else :
43
51
jars_depset = depset (transitive = [associate [JavaInfo ].compile_jars ])
44
- return jars_depset
52
+ return struct (
53
+ jars = jars_depset ,
54
+ abi_jars_set = abi_jars_set ,
55
+ )
56
+
57
+ def _java_info (target ):
58
+ return target [JavaInfo ] if JavaInfo in target else None
45
59
46
60
def _get_associates (ctx , toolchains , associates ):
47
61
"""Creates a struct of associates meta data"""
48
62
if not associates :
49
63
return struct (
50
64
module_name = _utils .derive_module_name (ctx ),
51
65
jars = depset (),
66
+ abi_jar_set = _sets .new (),
67
+ dep_infos = [],
52
68
)
53
69
elif ctx .attr .module_name :
54
70
fail ("If associates have been set then module_name cannot be provided" )
55
71
else :
56
72
jars = []
73
+ abi_jar_set = {}
57
74
module_names = []
75
+ java_infos = []
58
76
for a in associates :
59
- jars .append (_collect_associates (ctx = ctx , toolchains = toolchains , associate = a ))
77
+ jar_bundle = _collect_associates (ctx = ctx , toolchains = toolchains , associate = a )
78
+ jars .append (jar_bundle .jars )
79
+ abi_jar_set = jar_bundle .abi_jars_set
60
80
module_names .append (a [_KtJvmInfo ].module_name )
81
+ java_infos .append (_java_info (a ))
61
82
module_names = list (_sets .copy_of (module_names ))
62
83
63
84
if len (module_names ) > 1 :
@@ -69,7 +90,9 @@ def _get_associates(ctx, toolchains, associates):
69
90
fail ("Error in rules - a KtJvmInfo was found which did not have a module_name" )
70
91
return struct (
71
92
jars = depset (transitive = jars ),
93
+ abi_jar_set = abi_jar_set ,
72
94
module_name = module_names [0 ],
95
+ dep_infos = java_infos ,
73
96
)
74
97
75
98
associate_utils = struct (
0 commit comments