diff --git a/kotlin/BUILD b/kotlin/BUILD index 53e388ac8..4510269ab 100644 --- a/kotlin/BUILD +++ b/kotlin/BUILD @@ -39,6 +39,15 @@ bzl_library( ], ) +bzl_library( + name = "android", + srcs = ["android.bzl"], + visibility = ["//kotlin:__subpackages__"], + deps = [ + "//kotlin/internal", + ], +) + stardoc( name = "stardoc", out = "kotlin.md", @@ -59,6 +68,7 @@ stardoc( "kt_javac_options", ], deps = [ + "android", "kotlin", ], ) diff --git a/kotlin/android.bzl b/kotlin/android.bzl new file mode 100644 index 000000000..6095ad60b --- /dev/null +++ b/kotlin/android.bzl @@ -0,0 +1,8 @@ +load( + "//kotlin/internal/jvm:android.bzl", + _kt_android_library = "kt_android_library", + _kt_android_local_test = "kt_android_local_test", +) + +kt_android_library = _kt_android_library +kt_android_local_test = _kt_android_local_test diff --git a/kotlin/internal/jvm/android.bzl b/kotlin/internal/jvm/android.bzl index f29e4c226..1eeb4fb15 100644 --- a/kotlin/internal/jvm/android.bzl +++ b/kotlin/internal/jvm/android.bzl @@ -1,5 +1,3 @@ -load("@rules_android//android:rules.bzl", "android_library", "android_local_test") - # Copyright 2018 The Bazel Authors. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -40,7 +38,7 @@ def _kt_android_artifact( # TODO(bazelbuild/rules_kotlin/issues/273): This should be retrieved from a provider. base_deps = deps + [_ANDROID_SDK_JAR] - android_library( + native.android_library( name = base_name, visibility = ["//visibility:private"], exports = base_deps, @@ -70,7 +68,7 @@ def kt_android_library(name, exports = [], visibility = None, **kwargs): `srcs`, `deps`, `plugins` are routed to `kt_jvm_library` the other android related attributes are handled by the native `android_library` rule. """ - android_library( + native.android_library( name = name, exports = exports + _kt_android_artifact(name, **kwargs), visibility = visibility, @@ -96,7 +94,7 @@ def kt_android_local_test( related attributes are handled by the native `android_library` rule while the test attributes are picked out and handled by the `android_local_test` rule. """ - android_local_test( + native.android_local_test( name = name, deps = kwargs.get("deps", []) + _kt_android_artifact(name = name, testonly = True, **kwargs), jvm_flags = jvm_flags, diff --git a/kotlin/js.bzl b/kotlin/js.bzl new file mode 100644 index 000000000..2e454a20e --- /dev/null +++ b/kotlin/js.bzl @@ -0,0 +1,8 @@ +load( + "//kotlin/internal/js:js.bzl", + _kt_js_import = "kt_js_import_macro", + _kt_js_library = "kt_js_library_macro", +) + +kt_js_import = _kt_js_import +kt_js_library = _kt_js_library diff --git a/kotlin/jvm.bzl b/kotlin/jvm.bzl new file mode 100644 index 000000000..3690001b2 --- /dev/null +++ b/kotlin/jvm.bzl @@ -0,0 +1,14 @@ +load( + "//kotlin/internal/jvm:jvm.bzl", + _kt_compiler_plugin = "kt_compiler_plugin", + _kt_jvm_binary = "kt_jvm_binary", + _kt_jvm_import = "kt_jvm_import", + _kt_jvm_library = "kt_jvm_library", + _kt_jvm_test = "kt_jvm_test", +) + +kt_compiler_plugin = _kt_compiler_plugin +kt_jvm_binary = _kt_jvm_binary +kt_jvm_import = _kt_jvm_import +kt_jvm_library = _kt_jvm_library +kt_jvm_test = _kt_jvm_test diff --git a/kotlin/lint.bzl b/kotlin/lint.bzl new file mode 100644 index 000000000..e37c8d848 --- /dev/null +++ b/kotlin/lint.bzl @@ -0,0 +1,7 @@ +load("//kotlin/internal/lint:ktlint_config.bzl", _ktlint_config = "ktlint_config") +load("//kotlin/internal/lint:ktlint_fix.bzl", _ktlint_fix = "ktlint_fix") +load("//kotlin/internal/lint:ktlint_test.bzl", _ktlint_test = "ktlint_test") + +ktlint_fix = _ktlint_fix +ktlint_test = _ktlint_test +ktlint_config = _ktlint_config diff --git a/kotlin/rules.bzl b/kotlin/rules.bzl index e4ee1180f..b4918a642 100644 --- a/kotlin/rules.bzl +++ b/kotlin/rules.bzl @@ -25,7 +25,7 @@ load( _kt_kotlinc_options = "kt_kotlinc_options", ) load( - "//kotlin/internal/jvm:jvm.bzl", + ":jvm.bzl", _kt_compiler_plugin = "kt_compiler_plugin", _kt_jvm_binary = "kt_jvm_binary", _kt_jvm_import = "kt_jvm_import", @@ -33,32 +33,127 @@ load( _kt_jvm_test = "kt_jvm_test", ) load( - "//kotlin/internal/jvm:android.bzl", + ":android.bzl", _kt_android_library = "kt_android_library", _kt_android_local_test = "kt_android_local_test", ) load( - "//kotlin/internal/js:js.bzl", + ":js.bzl", _kt_js_import = "kt_js_import_macro", _kt_js_library = "kt_js_library_macro", ) -load("//kotlin/internal/lint:ktlint_config.bzl", _ktlint_config = "ktlint_config") -load("//kotlin/internal/lint:ktlint_fix.bzl", _ktlint_fix = "ktlint_fix") -load("//kotlin/internal/lint:ktlint_test.bzl", _ktlint_test = "ktlint_test") +load( + ":lint.bzl", + _ktlint_config = "ktlint_config", + _ktlint_fix = "ktlint_fix", + _ktlint_test = "ktlint_test", +) define_kt_toolchain = _define_kt_toolchain + kt_kotlinc_options = _kt_kotlinc_options + kt_javac_options = _kt_javac_options -kt_js_library = _kt_js_library -kt_js_import = _kt_js_import + +def kt_js_library(**kwargs): + """ + Forwarding macro for kt_js_library + + Deprecated: + kt_js_library should be loaded from //kotlin:js.bzl + """ + _kt_js_library(**kwargs) + +def kt_js_import(**kwargs): + """ + Forwarding macro for kt_js_import + + Deprecated: + kt_js_import should be loaded from //kotlin:js.bzl + """ + _kt_js_import(**kwargs) + kt_register_toolchains = _kt_register_toolchains -kt_jvm_binary = _kt_jvm_binary -kt_jvm_import = _kt_jvm_import -kt_jvm_library = _kt_jvm_library -kt_jvm_test = _kt_jvm_test -kt_android_library = _kt_android_library -kt_android_local_test = _kt_android_local_test + +def kt_jvm_binary(**kwargs): + """ + Forwarding macro for kt_jvm_binary + + Deprecated: + kt_jvm_binary should be loaded from //kotlin:jvm.bzl + """ + _kt_jvm_binary(**kwargs) + +def kt_jvm_import(**kwargs): + """ + Forwarding macro for kt_jvm_import + + Deprecated: + kt_jvm_import should be loaded from //kotlin:jvm.bzl + """ + _kt_jvm_import(**kwargs) + +def kt_jvm_library(**kwargs): + """ + Forwarding macro for kt_jvm_library + + Deprecated: + kt_jvm_library should be loaded from //kotlin:jvm.bzl + """ + _kt_jvm_library(**kwargs) + +def kt_jvm_test(**kwargs): + """ + Forwarding macro for kt_jvm_test + + Deprecated: + kt_jvm_test should be loaded from //kotlin:jvm.bzl + """ + _kt_jvm_test(**kwargs) + +def kt_android_library(**kwargs): + """ + Forwarding macro for kt_android_local_test + + Deprecated: + kt_android_library should be loaded from //kotlin:android.bzl + """ + _kt_android_library(**kwargs) + +def kt_android_local_test(**kwargs): + """ + Forwarding macro for kt_android_local_test + + Deprecated: + kt_android_local_test should be loaded from //kotlin:android.bzl + """ + _kt_android_local_test(**kwargs) + kt_compiler_plugin = _kt_compiler_plugin -ktlint_config = _ktlint_config -ktlint_fix = _ktlint_fix -ktlint_test = _ktlint_test + +def ktlint_config(**kwargs): + """ + Forwarding macro for ktlint_config + + Deprecated: + ktlint_config should be loaded from //kotlin:lint.bzl + """ + _ktlint_config(**kwargs) + +def ktlint_fix(**kwargs): + """ + Forwarding macro for ktlint_fix + + Deprecated: + ktlint_fix should be loaded from //kotlin:lint.bzl + """ + _ktlint_fix(**kwargs) + +def ktlint_test(**kwargs): + """ + Forwarding macro for ktlint_test + + Deprecated: + ktlint_test should be loaded from //kotlin:lint.bzl + """ + _ktlint_test(**kwargs)