Fix non-file inclusion into runfiles for data. Add runtime_deps and data as sources for runfiles.
diff --git a/kotlin/internal/jvm/impl.bzl b/kotlin/internal/jvm/impl.bzl index 1c31861..c84d415 100644 --- a/kotlin/internal/jvm/impl.bzl +++ b/kotlin/internal/jvm/impl.bzl
@@ -224,13 +224,13 @@ ) return _make_providers( ctx, - _compile.kt_jvm_produce_jar_actions(ctx, "kt_jvm_library") if ctx.attr.srcs or ctx.attr.resources else _compile.export_only_providers( + providers = _compile.kt_jvm_produce_jar_actions(ctx, "kt_jvm_library") if ctx.attr.srcs or ctx.attr.resources else _compile.export_only_providers( ctx = ctx, actions = ctx.actions, outputs = ctx.outputs, attr = ctx.attr, ), - runfiles_targets = ctx.attr.deps + ctx.attr.exports, + runfiles_targets = ctx.attr.deps + ctx.attr.exports + ctx.attr.runtime_deps + ctx.attr.data, ) def kt_jvm_binary_impl(ctx): @@ -251,12 +251,12 @@ return _make_providers( ctx, providers, - runfiles_targets = ctx.attr.deps, transitive_files = depset( order = "default", transitive = [providers.java.transitive_runtime_jars], direct = ctx.files._java_runtime, ), + runfiles_targets = ctx.attr.deps + ctx.attr.runtime_deps + ctx.attr.data, ) _SPLIT_STRINGS = [ @@ -308,7 +308,7 @@ return _make_providers( ctx, providers, - ctx.attr.deps, + ctx.attr.deps + ctx.attr.runtime_deps + ctx.attr.data, depset( order = "default", transitive = [runtime_jars, depset(coverage_runfiles), depset(coverage_metadata)],
diff --git a/src/main/starlark/core/compile/rules.bzl b/src/main/starlark/core/compile/rules.bzl index 668ee77..767d529 100644 --- a/src/main/starlark/core/compile/rules.bzl +++ b/src/main/starlark/core/compile/rules.bzl
@@ -110,7 +110,7 @@ files = ctx.files.data, ).merge_all([ d[DefaultInfo].default_runfiles - for d in ctx.attr.deps + ctx.attr.exports + for d in ctx.attr.deps + ctx.attr.exports + ctx.attr.data + ctx.attr.runtime_deps if DefaultInfo in d ]), ), @@ -166,7 +166,7 @@ transitive_files = launch_runfiles, ).merge_all([ d[DefaultInfo].default_runfiles - for d in ctx.attr.deps + for d in ctx.attr.deps + ctx.attr.data + ctx.attr.runtime_deps if DefaultInfo in d ]), executable = executable,
diff --git a/src/test/starlark/compile/rule_tests.bzl b/src/test/starlark/compile/rule_tests.bzl index 5cb966c..b89cce0 100644 --- a/src/test/starlark/compile/rule_tests.bzl +++ b/src/test/starlark/compile/rule_tests.bzl
@@ -122,7 +122,84 @@ return _case -def _test_deps_core( +def _test_runfiles( + rule_under_test, + compile_mnemonic, + srcjar_ext = ".srcjar", + additional_compile_libs = [], + **kwargs): + def _case(test): + transitive_data_file = test.artifact("transitive_data.file") + transitive_data = test.have( + rule_under_test, + name = "transitive_data", + srcs = [], + deps = [], + data = [transitive_data_file], + **kwargs + ) + data_file = test.artifact("data.file") + data = test.have( + rule_under_test, + name = "data", + srcs = [], + runtime_deps = [transitive_data], + data = [data_file], + **kwargs + ) + + got = test.got( + rule_under_test, + name = "got", + srcs = [ + test.artifact("gave.kt"), + ], + deps = [ + data, + ], + **kwargs + ) + test.claim( + got = got, + what = _outputs, + wants = { + "class_jar": Want( + attr = attr.label(allow_single_file = True), + value = got + ".jar", + ), + "source_jar": Want( + attr = attr.label(allow_single_file = True), + value = got + srcjar_ext, + ), + "inputs": Want( + attr = attr.label_list(allow_empty = True, allow_files = True), + value = [data], + ), + "transitive_compile_deps": Want( + attr = attr.label_list(providers = [[JavaInfo], [KtJvmInfo]]), + value = [data, got] + additional_compile_libs, + ), + "transitive_runtime_deps": Want( + attr = attr.label_list(providers = [[JavaInfo], [KtJvmInfo]]), + value = [got], + ), + "compile_mnemonic": Want( + attr = attr.string(), + value = compile_mnemonic, + ), + "runfiles": Want( + attr = attr.label_list(allow_empty = True, allow_files = True), + value = [ + data_file, + transitive_data_file, + ], + ), + }, + ) + + return _case + +def _test_deps( rule_under_test, compile_mnemonic, srcjar_ext = ".srcjar", @@ -344,13 +421,14 @@ compile_mnemonic = COMPILE_MNEMONIC, ) return dict( - test_deps_core_kt_jvm_binary = _test_deps_core(**binary), + test_deps_core_kt_jvm_binary = _test_deps(**binary), test_neverlink_deps_core_kt_jvm_binary = _test_neverlink_deps(**binary), test_no_deps_core_kt_jvm_binary = _test_no_deps(**binary), - test_deps_core_kt_jvm_library = _test_deps_core(**library), + test_deps_core_kt_jvm_library = _test_deps(**library), test_neverlink_deps_core_kt_jvm_library = _test_neverlink_deps(**library), test_no_deps_core_kt_jvm_library = _test_no_deps(**library), test_exports_core_kt_jvm_library = _test_exports(**library), + test_runfiles_core = _test_runfiles(**library), ) def test_jvm(): @@ -366,10 +444,11 @@ ], ) return dict( - test_deps_kt_jvm_library = _test_deps_core(**library), + test_deps_kt_jvm_library = _test_deps(**library), test_neverlink_deps_kt_jvm_library = _test_neverlink_deps(**library), test_no_deps_kt_jvm_library = _test_no_deps(**library), test_exports_kt_jvm_library = _test_exports(**library), + test_runfiles = _test_runfiles(**library), ) def test_suite(name):