Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions kotlin/internal/jvm/jvm_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ def _jvm_deps(ctx, toolchains, associate_deps, deps, exports = [], runtime_deps
] + [
d.transitive_compile_time_jars
for d in dep_infos
] + [
d.transitive_compile_time_jars
for d in associates.dep_infos
]

compile_depset_list = depset(transitive = transitive + [associates.jars]).to_list()
Expand Down
67 changes: 67 additions & 0 deletions src/test/starlark/internal/jvm/jvm_deps_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,69 @@ def _transitive_from_exports_test_impl(env, target):
classpath.contains(_file(env.ctx.attr.associate_jar).short_path)
classpath.not_contains(_file(env.ctx.attr.associate_abi_jar).short_path)

def _transitive_from_associates_test_impl(env, target):
##
# the one where target A associates with target B
# target B has a dependency to target C
# target A uses C, the world explodes
# what this means is the associates transitive_compile_time_jars has this
# <generated file B.jar>,
# <generated file C.jar>,
# <source file various-sdk-libs.jar>
# we will use the "direct jar" as a direct dep of the associate ie C
##
associates_direct_deps = [
JavaInfo(
compile_jar = _file(env.ctx.attr.direct_dep_jar),
output_jar = _file(env.ctx.attr.direct_dep_jar),
),
]

associate_deps = [
{
JavaInfo: JavaInfo(
compile_jar = _file(env.ctx.attr.associate_jar),
output_jar = _file(env.ctx.attr.associate_jar),
deps = associates_direct_deps,
),
_KtJvmInfo: _KtJvmInfo(
module_name = "associate_name",
),
},
]

fake_ctx = struct(
label = target.label,
attr = struct(
module_name = "",
tags = [],
),
)

nothing_configured_toolchains = struct(
kt = struct(
experimental_remove_private_classes_in_abi_jars = False,
experimental_prune_transitive_deps = False,
experimental_strict_associate_dependencies = False,
jvm_stdlibs = JavaInfo(
compile_jar = _file(env.ctx.attr.jvm_jar),
output_jar = _file(env.ctx.attr.jvm_jar),
),
),
)

result = _jvm_deps_utils.jvm_deps(
ctx = fake_ctx,
toolchains = nothing_configured_toolchains,
associate_deps = associate_deps,
deps = [],
)

classpath = env.expect.that_depset_of_files(result.compile_jars)

classpath.contains(_file(env.ctx.attr.direct_dep_jar).short_path)
classpath.contains(_file(env.ctx.attr.associate_jar).short_path)

def _abi_test(name, impl):
util.helper_target(
native.filegroup,
Expand Down Expand Up @@ -200,12 +263,16 @@ def _fat_abi_test(name):
def _transitive_from_exports_test(name):
_abi_test(name, _transitive_from_exports_test_impl)

def _transitive_from_associates_test(name):
_abi_test(name, _transitive_from_associates_test_impl)

def jvm_deps_test_suite(name):
test_suite(
name,
tests = [
_strict_abi_test,
_fat_abi_test,
_transitive_from_exports_test,
_transitive_from_associates_test,
],
)