Skip to content

Conversation

Bencodes
Copy link
Collaborator

@Bencodes Bencodes commented Jan 12, 2025

Enables support for strict Kotlin associate dependencies.

When --@rules_kotlin//kotlin/settings:experimental_strict_associate_dependencies=True is enabled, rules_kotlin will collect ONLY the direct java_output.compile_jar for each given associate dependency, ensuring that only the Kotlin internals for the targets explicitly listed out as associates will be exposed.

This behavior differs from what's currently in rules_kotlin where it collects the entire transitive compile jars classpath for each associate dependency, which technically leaks the Kotlin internals of the entire classpath for each associate dependency.

#1021

@restingbull
Copy link
Collaborator

We should add a readme section for this.

module_names = []
for a in associates:
jars.append(depset(transitive = [a[JavaInfo].compile_jars, a[_KtJvmInfo].module_jars]))
jars.append(_collect_associates(ctx = ctx, toolchains = toolchains, associate = a))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unclear if the a[_KtJvmInfo].module_jars still needs to be included here. We don't hit this case in our codebase and I don't have enough historical context around why we need this here.

@restingbull restingbull merged commit 7c57e0c into master Feb 21, 2025
2 checks passed
@Bencodes Bencodes deleted the add-support-for-strict-associate-deps branch February 24, 2025 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants