rules_kotlin
rules_kotlin copied to clipboard
Add support for experimental treatInternalAsPrivate and removePrivateClasses in abi.jar
This is in relation to https://youtrack.jetbrains.com/issue/KT-65690 and https://youtrack.jetbrains.com/issue/KT-64590
Current ABI jar generation includes not only public classes but internal and in some instances private which I belives can lead to unnecessary build invalidations.
As far as I can tell we would need to include optional configuration of the jvm-abi plugin in or around here
You might expect something along these lines in that file
plugin(plugins.jvmAbiGen) {
flag("outputDir", directories.abiClasses)
if(task.info.publicOnlyAbiJar) {
flag("treatInternalAsPrivate", "true")
flag("removePrivateClasses", "true")
}
}
I think it would make sense to bundle both these plugin options behind one experimental flag on the rule.
Your thoughts on this?
Im currently exploring how this might look in the codebase but progress is slow (however I do have a failing test for the core part of this)
If I get this to work im thinking of extending the CompilationTaskInfo proto with
bool public_only_abi_jar = 12;
and adding this attribute to kt_toolchain
"experimental_use_public_only_abi_jars": attr.bool(
doc = """Compile using public only abi jars.
This applies the following two compiler plugin options.
plugin:org.jetbrains.kotlin.jvm.abi:treatInternalAsPrivate=true
plugin:org.jetbrains.kotlin.jvm.abi:removePrivateClasses=true
Can be disabled for an individual target using the tag.
`kt_abi_plugin_incompatible`""",
default = False,
),
plus all the other bits, however I think these are the ones worth early discussion
Ive opened a draft pr for your consideration
implemented in #1248