aboutsummaryrefslogtreecommitdiff
path: root/tests/jvm
diff options
context:
space:
mode:
Diffstat (limited to 'tests/jvm')
-rw-r--r--tests/jvm/analysis/compiler_plugin/forbidden_target/BUILD23
-rw-r--r--tests/jvm/analysis/compiler_plugin/provider_ctor/BUILD24
-rw-r--r--tests/jvm/analysis/compiler_plugin/provider_ctor/unittests.bzl34
-rw-r--r--tests/jvm/analysis/jvm_compile/no_srcs/BUILD63
-rw-r--r--tests/jvm/analysis/jvm_compile/r_java/BUILD61
-rw-r--r--tests/jvm/analysis/jvm_compile/r_java/Input.java16
-rw-r--r--tests/jvm/analysis/jvm_compile/r_java/Input.kt17
-rw-r--r--tests/jvm/analysis/jvm_compile/src_artifacts/BUILD61
-rw-r--r--tests/jvm/analysis/jvm_import/jars/BUILD45
-rw-r--r--tests/jvm/analysis/jvm_import/runtime_deps/BUILD42
-rw-r--r--tests/jvm/analysis/jvm_import/srcjar/BUILD35
-rw-r--r--tests/jvm/analysis/jvm_library/coverage/BUILD66
-rw-r--r--tests/jvm/analysis/jvm_library/coverage/CommonSrc.kt17
-rw-r--r--tests/jvm/analysis/jvm_library/coverage/Data.java16
-rw-r--r--tests/jvm/analysis/jvm_library/coverage/Dep.java16
-rw-r--r--tests/jvm/analysis/jvm_library/coverage/Resource.java16
-rw-r--r--tests/jvm/analysis/jvm_library/coverage/RuntimeDep.java16
-rw-r--r--tests/jvm/analysis/jvm_library/coverage/Src.kt17
-rw-r--r--tests/jvm/analysis/jvm_library/data/BUILD41
-rw-r--r--tests/jvm/analysis/jvm_library/data/Input.kt17
-rw-r--r--tests/jvm/analysis/jvm_library/data/data.txt27
-rw-r--r--tests/jvm/analysis/jvm_library/deps/BUILD62
-rw-r--r--tests/jvm/analysis/jvm_library/deps/Input.java16
-rw-r--r--tests/jvm/analysis/jvm_library/deps/Input.kt17
-rw-r--r--tests/jvm/analysis/jvm_library/exports/BUILD66
-rw-r--r--tests/jvm/analysis/jvm_library/exports/Input.java16
-rw-r--r--tests/jvm/analysis/jvm_library/exports/Input.kt17
-rw-r--r--tests/jvm/analysis/jvm_library/forbidden_deps/BUILD54
-rw-r--r--tests/jvm/analysis/jvm_library/forbidden_deps/Input.kt17
-rw-r--r--tests/jvm/analysis/jvm_library/friends/BUILD110
-rw-r--r--tests/jvm/analysis/jvm_library/friends/Input.java19
-rw-r--r--tests/jvm/analysis/jvm_library/friends/Input.kt17
-rw-r--r--tests/jvm/analysis/jvm_library/friends/sub/BUILD58
-rw-r--r--tests/jvm/analysis/jvm_library/friends/sub/Input.kt17
-rw-r--r--tests/jvm/analysis/jvm_library/friends/testing/BUILD89
-rw-r--r--tests/jvm/analysis/jvm_library/friends/testing/Input.kt17
-rw-r--r--tests/jvm/analysis/jvm_library/no_srcs/BUILD69
-rw-r--r--tests/jvm/analysis/jvm_library/no_srcs/Input.java16
-rw-r--r--tests/jvm/analysis/jvm_library/no_srcs/Input.kt17
-rw-r--r--tests/jvm/analysis/jvm_library/only_common_srcs/BUILD33
-rw-r--r--tests/jvm/analysis/jvm_library/only_common_srcs/Input.kt17
-rw-r--r--tests/jvm/analysis/jvm_library/plugins/BUILD153
-rw-r--r--tests/jvm/analysis/jvm_library/plugins/Input.java16
-rw-r--r--tests/jvm/analysis/jvm_library/plugins/Input.kt17
-rw-r--r--tests/jvm/analysis/jvm_library/resources/BUILD32
-rw-r--r--tests/jvm/analysis/jvm_library/resources/Input.kt17
-rw-r--r--tests/jvm/analysis/jvm_library/resources/resource.txt14
-rw-r--r--tests/jvm/analysis/jvm_library/runtime_deps/BUILD41
-rw-r--r--tests/jvm/analysis/jvm_library/runtime_deps/Input.java16
-rw-r--r--tests/jvm/analysis/jvm_library/runtime_deps/Input.kt17
-rw-r--r--tests/jvm/analysis/jvm_library/treeartifacts_srcs/BUILD106
-rw-r--r--tests/jvm/analysis/jvm_library/treeartifacts_srcs/Input.java16
-rw-r--r--tests/jvm/analysis/jvm_library/treeartifacts_srcs/Input.kt17
-rw-r--r--tests/jvm/analysis/util/file_factory/BUILD25
-rw-r--r--tests/jvm/analysis/util/file_factory/unittests.bzl85
-rw-r--r--tests/jvm/java/neverlink/BUILD8
-rw-r--r--tests/jvm/java/srcartifacts/BUILD17
57 files changed, 1999 insertions, 12 deletions
diff --git a/tests/jvm/analysis/compiler_plugin/forbidden_target/BUILD b/tests/jvm/analysis/compiler_plugin/forbidden_target/BUILD
new file mode 100644
index 0000000..d21f27c
--- /dev/null
+++ b/tests/jvm/analysis/compiler_plugin/forbidden_target/BUILD
@@ -0,0 +1,23 @@
+# Copyright 2022 Google LLC. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the License);
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+load("//kotlin/common/testing:testing_rules.bzl", "kt_testing_rules")
+load("//kotlin/jvm/testing:for_analysis.bzl", ktfa = "kt_for_analysis")
+
+package(
+ default_applicable_licenses = ["//:license"],
+ default_testonly = True,
+)
+
+licenses(["notice"])
diff --git a/tests/jvm/analysis/compiler_plugin/provider_ctor/BUILD b/tests/jvm/analysis/compiler_plugin/provider_ctor/BUILD
new file mode 100644
index 0000000..0ba8b21
--- /dev/null
+++ b/tests/jvm/analysis/compiler_plugin/provider_ctor/BUILD
@@ -0,0 +1,24 @@
+# Copyright 2022 Google LLC. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the License);
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+load(":unittests.bzl", "unittests")
+
+package(
+ default_applicable_licenses = ["//:license"],
+ default_testonly = True,
+)
+
+licenses(["notice"])
+
+unittests.render(name = "unittests")
diff --git a/tests/jvm/analysis/compiler_plugin/provider_ctor/unittests.bzl b/tests/jvm/analysis/compiler_plugin/provider_ctor/unittests.bzl
new file mode 100644
index 0000000..e43744f
--- /dev/null
+++ b/tests/jvm/analysis/compiler_plugin/provider_ctor/unittests.bzl
@@ -0,0 +1,34 @@
+# Copyright 2022 Google LLC. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the License);
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""unittests"""
+
+load("//:visibility.bzl", "RULES_KOTLIN")
+load("//kotlin:compiler_plugin.bzl", "KtCompilerPluginInfo")
+load("//kotlin/common/testing:unittest_suites.bzl", "kt_unittest_suites")
+
+visibility(RULES_KOTLIN)
+
+unittests = kt_unittest_suites.create()
+
+def _cannot_construct_provider(ctx):
+ KtCompilerPluginInfo(
+ plugin_id = "fake",
+ jar = ctx.actions.declare_file("fake.jar"),
+ args = [],
+ )
+
+unittests.expect_fail(_cannot_construct_provider, "Error in fail")
+
+_test, _fail = unittests.close() # @unused
diff --git a/tests/jvm/analysis/jvm_compile/no_srcs/BUILD b/tests/jvm/analysis/jvm_compile/no_srcs/BUILD
new file mode 100644
index 0000000..6de9ffb
--- /dev/null
+++ b/tests/jvm/analysis/jvm_compile/no_srcs/BUILD
@@ -0,0 +1,63 @@
+# Copyright 2022 Google LLC. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the License);
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+load("//kotlin:common.bzl", "common")
+load("//kotlin/common/testing:testing_rules.bzl", "kt_testing_rules")
+load("//kotlin/jvm/testing:for_analysis.bzl", ktfa = "kt_for_analysis")
+load("//kotlin/jvm/testing:jvm_compile_stubs.bzl", "kt_jvm_compile_stubs")
+
+package(
+ default_applicable_licenses = ["//:license"],
+ default_testonly = True,
+)
+
+licenses(["notice"])
+
+kt_jvm_compile_stubs.analysis_test(
+ name = "no_srcs_android_family_test",
+ target_under_test = kt_jvm_compile_stubs.rule(
+ name = "no_srcs_android_family",
+ srcs = [],
+ common_srcs = [],
+ rule_family = common.RULE_FAMILY.ANDROID_LIBRARY,
+ ),
+)
+
+kt_testing_rules.assert_failure_test(
+ name = "no_srcs_jvm_family_test",
+ msg_contains = "Expected one of (srcs, common_srcs, exports) is not empty",
+ target_under_test = kt_jvm_compile_stubs.rule(
+ name = "no_srcs_jvm_family",
+ srcs = [],
+ common_srcs = [],
+ rule_family = common.RULE_FAMILY.JVM_LIBRARY,
+ exports = [],
+ ),
+)
+
+kt_jvm_compile_stubs.analysis_test(
+ name = "no_srcs_jvm_family_with_exports_test",
+ target_under_test = kt_jvm_compile_stubs.rule(
+ name = "no_srcs_jvm_family_with_exports",
+ srcs = [],
+ common_srcs = [],
+ rule_family = common.RULE_FAMILY.ANDROID_LIBRARY,
+ exports = [
+ ktfa.java_library(
+ name = "no_srcs_jvm_family_export",
+ srcs = [],
+ ),
+ ],
+ ),
+)
diff --git a/tests/jvm/analysis/jvm_compile/r_java/BUILD b/tests/jvm/analysis/jvm_compile/r_java/BUILD
new file mode 100644
index 0000000..70ef77c
--- /dev/null
+++ b/tests/jvm/analysis/jvm_compile/r_java/BUILD
@@ -0,0 +1,61 @@
+# Copyright 2022 Google LLC. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the License);
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+load("//kotlin/common/testing:testing_rules.bzl", "kt_testing_rules")
+load("//kotlin/jvm/testing:for_analysis.bzl", ktfa = "kt_for_analysis")
+load("//kotlin/jvm/testing:jvm_compile_stubs.bzl", "kt_jvm_compile_stubs")
+
+package(
+ default_applicable_licenses = ["//:license"],
+ default_testonly = True,
+)
+
+licenses(["notice"])
+
+kt_jvm_compile_stubs.analysis_test(
+ name = "has_r_java_named_resources_test",
+ expected_kotlinc_classpath_names = [
+ "platformclasspath.jar", # bootclasspath
+ "libjava_library_resources-hjar.jar", # r_java
+ "libjava_library-hjar.jar", # deps
+ "kotlin-stdlib-ijar.jar", # stdlibs
+ "annotations-13.0-ijar.jar", # stdlibs
+ ],
+ target_under_test = kt_jvm_compile_stubs.rule(
+ name = "has_r_java_named_resources",
+ srcs = ["Input.kt"],
+ r_java = ":java_library_resources",
+ deps = [":java_library"],
+ ),
+)
+
+kt_testing_rules.assert_failure_test(
+ name = "has_r_java_not_named_resources_test",
+ msg_contains = "illegal dependency provided for r_java",
+ target_under_test = kt_jvm_compile_stubs.rule(
+ name = "has_r_java_not_named_resources",
+ srcs = ["Input.kt"],
+ r_java = ":java_library",
+ ),
+)
+
+ktfa.java_library(
+ name = "java_library_resources",
+ srcs = ["Input.java"],
+)
+
+ktfa.java_library(
+ name = "java_library",
+ srcs = ["Input.java"],
+)
diff --git a/tests/jvm/analysis/jvm_compile/r_java/Input.java b/tests/jvm/analysis/jvm_compile/r_java/Input.java
new file mode 100644
index 0000000..e675bc1
--- /dev/null
+++ b/tests/jvm/analysis/jvm_compile/r_java/Input.java
@@ -0,0 +1,16 @@
+/*
+ * * Copyright 2022 Google LLC. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
diff --git a/tests/jvm/analysis/jvm_compile/r_java/Input.kt b/tests/jvm/analysis/jvm_compile/r_java/Input.kt
new file mode 100644
index 0000000..963d749
--- /dev/null
+++ b/tests/jvm/analysis/jvm_compile/r_java/Input.kt
@@ -0,0 +1,17 @@
+/*
+ * * Copyright 2022 Google LLC. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
diff --git a/tests/jvm/analysis/jvm_compile/src_artifacts/BUILD b/tests/jvm/analysis/jvm_compile/src_artifacts/BUILD
new file mode 100644
index 0000000..348c629
--- /dev/null
+++ b/tests/jvm/analysis/jvm_compile/src_artifacts/BUILD
@@ -0,0 +1,61 @@
+# Copyright 2022 Google LLC. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the License);
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+load("//kotlin/common/testing:testing_rules.bzl", "kt_testing_rules")
+load("//kotlin/jvm/testing:jvm_compile_stubs.bzl", "kt_jvm_compile_stubs")
+
+package(
+ default_applicable_licenses = ["//:license"],
+ default_testonly = True,
+)
+
+licenses(["notice"])
+
+kt_jvm_compile_stubs.analysis_test(
+ name = "has_allowed_aritfacts_test",
+ target_under_test = kt_jvm_compile_stubs.rule(
+ name = "has_allowed_artifacts",
+ srcs = [
+ # go/keep-sorted start
+ kt_testing_rules.create_dir(name = "has_allowed_artifacts/java"),
+ kt_testing_rules.create_dir(name = "has_allowed_artifacts/kotlin"),
+ kt_testing_rules.create_file(name = "has_allowed_artifacts/java.srcjar"),
+ kt_testing_rules.create_file(name = "has_allowed_artifacts/src.java"),
+ kt_testing_rules.create_file(name = "has_allowed_artifacts/src.kt"),
+ # go/keep-sorted end
+ ],
+ ),
+)
+
+kt_testing_rules.assert_failure_test(
+ name = "has_unexpected_file_type_test",
+ msg_contains = "/src.unexpected",
+ target_under_test = kt_jvm_compile_stubs.rule(
+ name = "has_unexpected_file_type",
+ srcs = [
+ kt_testing_rules.create_file(name = "has_unexpected_file_type/src.unexpected"),
+ ],
+ ),
+)
+
+kt_testing_rules.assert_failure_test(
+ name = "has_unexpected_dir_ending_test",
+ msg_contains = "/kotlin/unexpected",
+ target_under_test = kt_jvm_compile_stubs.rule(
+ name = "has_unexpected_dir_ending",
+ srcs = [
+ kt_testing_rules.create_dir(name = "has_unexpected_dir_ending_test/kotlin/unexpected"),
+ ],
+ ),
+)
diff --git a/tests/jvm/analysis/jvm_import/jars/BUILD b/tests/jvm/analysis/jvm_import/jars/BUILD
new file mode 100644
index 0000000..38b0b62
--- /dev/null
+++ b/tests/jvm/analysis/jvm_import/jars/BUILD
@@ -0,0 +1,45 @@
+# Copyright 2022 Google LLC. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the License);
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+load("//kotlin/common/testing:testing_rules.bzl", "kt_testing_rules")
+load("//kotlin/jvm/testing:for_analysis.bzl", "kt_for_analysis")
+load("//kotlin/jvm/testing:jvm_import_analysis_test.bzl", "kt_jvm_import_analysis_test")
+
+package(
+ default_applicable_licenses = ["//:license"],
+ default_testonly = True,
+)
+
+licenses(["notice"])
+
+kt_jvm_import_analysis_test(
+ name = "one_jar_test",
+ target_under_test = kt_for_analysis.kt_jvm_import(
+ name = "one_jar",
+ jars = [
+ kt_testing_rules.create_file(name = "one_jar.jar"),
+ ],
+ ),
+)
+
+kt_jvm_import_analysis_test(
+ name = "many_jar_test",
+ target_under_test = kt_for_analysis.kt_jvm_import(
+ name = "many_jar",
+ jars = [
+ kt_testing_rules.create_file(name = "many_jar_0.jar"),
+ kt_testing_rules.create_file(name = "many_jar_2.jar"),
+ ],
+ ),
+)
diff --git a/tests/jvm/analysis/jvm_import/runtime_deps/BUILD b/tests/jvm/analysis/jvm_import/runtime_deps/BUILD
new file mode 100644
index 0000000..a6692cc
--- /dev/null
+++ b/tests/jvm/analysis/jvm_import/runtime_deps/BUILD
@@ -0,0 +1,42 @@
+# Copyright 2022 Google LLC. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the License);
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+load("//kotlin/common/testing:testing_rules.bzl", "kt_testing_rules")
+load("//kotlin/jvm/testing:for_analysis.bzl", "kt_for_analysis")
+load("//kotlin/jvm/testing:jvm_import_analysis_test.bzl", "kt_jvm_import_analysis_test")
+
+package(
+ default_applicable_licenses = ["//:license"],
+ default_testonly = True,
+)
+
+licenses(["notice"])
+
+kt_jvm_import_analysis_test(
+ name = "runtime_deps_test",
+ target_under_test = kt_for_analysis.kt_jvm_import(
+ name = "runtime_deps",
+ jars = [
+ kt_testing_rules.create_file(name = "runtime_deps.jar"),
+ ],
+ runtime_deps = [
+ ":runtime_deps_test_dep",
+ ],
+ ),
+)
+
+kt_for_analysis.java_library(
+ name = "runtime_deps_test_dep",
+ srcs = [],
+)
diff --git a/tests/jvm/analysis/jvm_import/srcjar/BUILD b/tests/jvm/analysis/jvm_import/srcjar/BUILD
new file mode 100644
index 0000000..ea1b23c
--- /dev/null
+++ b/tests/jvm/analysis/jvm_import/srcjar/BUILD
@@ -0,0 +1,35 @@
+# Copyright 2022 Google LLC. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the License);
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+load("//kotlin/common/testing:testing_rules.bzl", "kt_testing_rules")
+load("//kotlin/jvm/testing:for_analysis.bzl", "kt_for_analysis")
+load("//kotlin/jvm/testing:jvm_import_analysis_test.bzl", "kt_jvm_import_analysis_test")
+
+package(
+ default_applicable_licenses = ["//:license"],
+ default_testonly = True,
+)
+
+licenses(["notice"])
+
+kt_jvm_import_analysis_test(
+ name = "has_srcjar_test",
+ target_under_test = kt_for_analysis.kt_jvm_import(
+ name = "has_srcjar",
+ jars = [
+ kt_testing_rules.create_file(name = "has_srcjar.jar"),
+ ],
+ srcjar = kt_testing_rules.create_file(name = "has_srcjar.srcjar"),
+ ),
+)
diff --git a/tests/jvm/analysis/jvm_library/coverage/BUILD b/tests/jvm/analysis/jvm_library/coverage/BUILD
new file mode 100644
index 0000000..284a7a8
--- /dev/null
+++ b/tests/jvm/analysis/jvm_library/coverage/BUILD
@@ -0,0 +1,66 @@
+# Copyright 2022 Google LLC. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the License);
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+load("//kotlin/common/testing:testing_rules.bzl", "kt_testing_rules")
+load("//kotlin/jvm/testing:for_analysis.bzl", ktfa = "kt_for_analysis")
+
+package(
+ default_applicable_licenses = ["//:license"],
+ default_testonly = True,
+)
+
+licenses(["notice"])
+
+kt_testing_rules.coverage_instrumentation_test(
+ name = "has_coverage_test",
+ expected_instrumented_file_names = [
+ "Data.java",
+ "Dep.java",
+ "Resource.java",
+ "RuntimeDep.java",
+ "Src.kt",
+ "CommonSrc.kt",
+ ],
+ target_under_test = ktfa.kt_jvm_library(
+ name = "has_coverage",
+ srcs = ["Src.kt"],
+ common_srcs = ["CommonSrc.kt"],
+ data = [":data"],
+ resources = [":resource"],
+ runtime_deps = [":runtime_dep"],
+ deps = [":dep"],
+ ),
+)
+
+ktfa.java_library(
+ name = "dep",
+ srcs = ["Dep.java"],
+)
+
+ktfa.java_library(
+ name = "runtime_dep",
+ srcs = ["RuntimeDep.java"],
+)
+
+ktfa.java_binary(
+ name = "data",
+ srcs = ["Data.java"],
+ main_class = "Data",
+)
+
+ktfa.java_binary(
+ name = "resource",
+ srcs = ["Resource.java"],
+ main_class = "Resources",
+)
diff --git a/tests/jvm/analysis/jvm_library/coverage/CommonSrc.kt b/tests/jvm/analysis/jvm_library/coverage/CommonSrc.kt
new file mode 100644
index 0000000..963d749
--- /dev/null
+++ b/tests/jvm/analysis/jvm_library/coverage/CommonSrc.kt
@@ -0,0 +1,17 @@
+/*
+ * * Copyright 2022 Google LLC. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
diff --git a/tests/jvm/analysis/jvm_library/coverage/Data.java b/tests/jvm/analysis/jvm_library/coverage/Data.java
new file mode 100644
index 0000000..e675bc1
--- /dev/null
+++ b/tests/jvm/analysis/jvm_library/coverage/Data.java
@@ -0,0 +1,16 @@
+/*
+ * * Copyright 2022 Google LLC. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
diff --git a/tests/jvm/analysis/jvm_library/coverage/Dep.java b/tests/jvm/analysis/jvm_library/coverage/Dep.java
new file mode 100644
index 0000000..e675bc1
--- /dev/null
+++ b/tests/jvm/analysis/jvm_library/coverage/Dep.java
@@ -0,0 +1,16 @@
+/*
+ * * Copyright 2022 Google LLC. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
diff --git a/tests/jvm/analysis/jvm_library/coverage/Resource.java b/tests/jvm/analysis/jvm_library/coverage/Resource.java
new file mode 100644
index 0000000..e675bc1
--- /dev/null
+++ b/tests/jvm/analysis/jvm_library/coverage/Resource.java
@@ -0,0 +1,16 @@
+/*
+ * * Copyright 2022 Google LLC. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
diff --git a/tests/jvm/analysis/jvm_library/coverage/RuntimeDep.java b/tests/jvm/analysis/jvm_library/coverage/RuntimeDep.java
new file mode 100644
index 0000000..e675bc1
--- /dev/null
+++ b/tests/jvm/analysis/jvm_library/coverage/RuntimeDep.java
@@ -0,0 +1,16 @@
+/*
+ * * Copyright 2022 Google LLC. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
diff --git a/tests/jvm/analysis/jvm_library/coverage/Src.kt b/tests/jvm/analysis/jvm_library/coverage/Src.kt
new file mode 100644
index 0000000..963d749
--- /dev/null
+++ b/tests/jvm/analysis/jvm_library/coverage/Src.kt
@@ -0,0 +1,17 @@
+/*
+ * * Copyright 2022 Google LLC. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
diff --git a/tests/jvm/analysis/jvm_library/data/BUILD b/tests/jvm/analysis/jvm_library/data/BUILD
new file mode 100644
index 0000000..92350c0
--- /dev/null
+++ b/tests/jvm/analysis/jvm_library/data/BUILD
@@ -0,0 +1,41 @@
+# Copyright 2022 Google LLC. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the License);
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+load("//kotlin/jvm/testing:for_analysis.bzl", "kt_for_analysis")
+load("//kotlin/jvm/testing:jvm_library_analysis_test.bzl", "kt_jvm_library_analysis_test")
+
+package(
+ default_applicable_licenses = ["//:license"],
+ default_testonly = True,
+)
+
+licenses(["notice"])
+
+kt_jvm_library_analysis_test(
+ name = "data_test",
+ expected_runfile_names = [
+ "data.txt",
+ # libX.jar is always in data_runfiles as well - just append it.
+ "libdata.jar",
+ ],
+ target_under_test = kt_for_analysis.kt_jvm_library(
+ name = "data",
+ srcs = [
+ "Input.kt",
+ ],
+ data = [
+ "data.txt",
+ ],
+ ),
+)
diff --git a/tests/jvm/analysis/jvm_library/data/Input.kt b/tests/jvm/analysis/jvm_library/data/Input.kt
new file mode 100644
index 0000000..963d749
--- /dev/null
+++ b/tests/jvm/analysis/jvm_library/data/Input.kt
@@ -0,0 +1,17 @@
+/*
+ * * Copyright 2022 Google LLC. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
diff --git a/tests/jvm/analysis/jvm_library/data/data.txt b/tests/jvm/analysis/jvm_library/data/data.txt
new file mode 100644
index 0000000..d146a73
--- /dev/null
+++ b/tests/jvm/analysis/jvm_library/data/data.txt
@@ -0,0 +1,27 @@
+# Copyright 2022 Google LLC. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the License);
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Copyright 2022 Google LLC. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the License);
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License. \ No newline at end of file
diff --git a/tests/jvm/analysis/jvm_library/deps/BUILD b/tests/jvm/analysis/jvm_library/deps/BUILD
new file mode 100644
index 0000000..fb01c01
--- /dev/null
+++ b/tests/jvm/analysis/jvm_library/deps/BUILD
@@ -0,0 +1,62 @@
+# Copyright 2022 Google LLC. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the License);
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+load("//kotlin/jvm/testing:for_analysis.bzl", "kt_for_analysis")
+load("//kotlin/jvm/testing:jvm_library_analysis_test.bzl", "kt_jvm_library_analysis_test")
+
+package(
+ default_applicable_licenses = ["//:license"],
+ default_testonly = True,
+)
+
+licenses(["notice"])
+
+kt_jvm_library_analysis_test(
+ name = "no_deps_test",
+ target_under_test = kt_for_analysis.kt_jvm_library(
+ name = "no_deps",
+ srcs = [
+ "Input.java",
+ "Input.kt",
+ ],
+ ),
+)
+
+kt_jvm_library_analysis_test(
+ name = "deps_test",
+ target_under_test = kt_for_analysis.kt_jvm_library(
+ name = "deps",
+ srcs = [
+ "Input.java",
+ ],
+ deps = [
+ ":deps_test_java_dep",
+ ":deps_test_kt_dep",
+ ],
+ ),
+)
+
+kt_for_analysis.kt_jvm_library(
+ name = "deps_test_kt_dep",
+ srcs = [
+ "Input.kt",
+ ],
+)
+
+kt_for_analysis.java_library(
+ name = "deps_test_java_dep",
+ srcs = [
+ "Input.java",
+ ],
+)
diff --git a/tests/jvm/analysis/jvm_library/deps/Input.java b/tests/jvm/analysis/jvm_library/deps/Input.java
new file mode 100644
index 0000000..e675bc1
--- /dev/null
+++ b/tests/jvm/analysis/jvm_library/deps/Input.java
@@ -0,0 +1,16 @@
+/*
+ * * Copyright 2022 Google LLC. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
diff --git a/tests/jvm/analysis/jvm_library/deps/Input.kt b/tests/jvm/analysis/jvm_library/deps/Input.kt
new file mode 100644
index 0000000..963d749
--- /dev/null
+++ b/tests/jvm/analysis/jvm_library/deps/Input.kt
@@ -0,0 +1,17 @@
+/*
+ * * Copyright 2022 Google LLC. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
diff --git a/tests/jvm/analysis/jvm_library/exports/BUILD b/tests/jvm/analysis/jvm_library/exports/BUILD
new file mode 100644
index 0000000..b2bb9c7
--- /dev/null
+++ b/tests/jvm/analysis/jvm_library/exports/BUILD
@@ -0,0 +1,66 @@
+# Copyright 2022 Google LLC. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the License);
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+load("//kotlin/jvm/testing:for_analysis.bzl", ktfa = "kt_for_analysis")
+load("//kotlin/jvm/testing:jvm_library_analysis_test.bzl", "kt_jvm_library_analysis_test")
+
+package(
+ default_applicable_licenses = ["//:license"],
+ default_testonly = True,
+)
+
+licenses(["notice"])
+
+kt_jvm_library_analysis_test(
+ name = "has_exports_test",
+ expected_compile_jar_names = [
+ # go/keep-sorted start
+ "libexports_transitive-compile.jar",
+ "libhas_exports-compile.jar",
+ "libjava_library-hjar.jar",
+ "libkt_jvm_library-compile.jar",
+ "libtransitive-compile.jar",
+ # go/keep-sorted end
+ ],
+ target_under_test = ktfa.kt_jvm_library(
+ name = "has_exports",
+ srcs = ["Input.kt"],
+ exports = [
+ ":exports_transitive",
+ ":java_library",
+ ":kt_jvm_library",
+ ],
+ ),
+)
+
+ktfa.kt_jvm_library(
+ name = "exports_transitive",
+ srcs = ["Input.kt"],
+ exports = [
+ ktfa.kt_jvm_library(
+ name = "transitive",
+ srcs = ["Input.kt"],
+ ),
+ ],
+)
+
+ktfa.kt_jvm_library(
+ name = "kt_jvm_library",
+ srcs = ["Input.kt"],
+)
+
+ktfa.java_library(
+ name = "java_library",
+ srcs = ["Input.java"], # need file here so we get a Jar
+)
diff --git a/tests/jvm/analysis/jvm_library/exports/Input.java b/tests/jvm/analysis/jvm_library/exports/Input.java
new file mode 100644
index 0000000..e675bc1
--- /dev/null
+++ b/tests/jvm/analysis/jvm_library/exports/Input.java
@@ -0,0 +1,16 @@
+/*
+ * * Copyright 2022 Google LLC. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
diff --git a/tests/jvm/analysis/jvm_library/exports/Input.kt b/tests/jvm/analysis/jvm_library/exports/Input.kt
new file mode 100644
index 0000000..963d749
--- /dev/null
+++ b/tests/jvm/analysis/jvm_library/exports/Input.kt
@@ -0,0 +1,17 @@
+/*
+ * * Copyright 2022 Google LLC. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
diff --git a/tests/jvm/analysis/jvm_library/forbidden_deps/BUILD b/tests/jvm/analysis/jvm_library/forbidden_deps/BUILD
new file mode 100644
index 0000000..5fcc02f
--- /dev/null
+++ b/tests/jvm/analysis/jvm_library/forbidden_deps/BUILD
@@ -0,0 +1,54 @@
+# Copyright 2022 Google LLC. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the License);
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+load("//kotlin/common/testing:testing_rules.bzl", "kt_testing_rules")
+load("//kotlin/jvm/testing:for_analysis.bzl", ktfa = "kt_for_analysis")
+
+package(
+ default_applicable_licenses = ["//:license"],
+ default_testonly = True,
+)
+
+licenses(["notice"])
+
+kt_testing_rules.assert_failure_test(
+ name = "has_forbidden_nano_dep_test",
+ msg_contains = "fake_nano_proto_lib",
+ target_under_test = ktfa.kt_jvm_library(
+ name = "has_forbidden_nano_dep",
+ srcs = ["Inputs.kt"],
+ deps = [":fake_nano_proto_lib"],
+ ),
+)
+
+kt_testing_rules.assert_failure_test(
+ name = "dep_on_has_forbidden_nano_export_test",
+ msg_contains = "fake_nano_proto_lib",
+ target_under_test = ktfa.kt_jvm_library(
+ name = "dep_on_has_forbidden_nano_export",
+ srcs = ["Input.kt"],
+ deps = [
+ ktfa.java_library(
+ name = "has_forbidden_nano_export",
+ exports = [":fake_nano_proto_lib"],
+ ),
+ ],
+ ),
+)
+
+ktfa.java_library(
+ name = "fake_nano_proto_lib",
+ srcs = [],
+ tags = ["nano_proto_library"],
+)
diff --git a/tests/jvm/analysis/jvm_library/forbidden_deps/Input.kt b/tests/jvm/analysis/jvm_library/forbidden_deps/Input.kt
new file mode 100644
index 0000000..963d749
--- /dev/null
+++ b/tests/jvm/analysis/jvm_library/forbidden_deps/Input.kt
@@ -0,0 +1,17 @@
+/*
+ * * Copyright 2022 Google LLC. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
diff --git a/tests/jvm/analysis/jvm_library/friends/BUILD b/tests/jvm/analysis/jvm_library/friends/BUILD
new file mode 100644
index 0000000..f2454f4
--- /dev/null
+++ b/tests/jvm/analysis/jvm_library/friends/BUILD
@@ -0,0 +1,110 @@
+# Copyright 2022 Google LLC. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the License);
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+load("//kotlin/jvm/testing:for_analysis.bzl", ktfa = "kt_for_analysis")
+load("//kotlin/jvm/testing:jvm_library_analysis_test.bzl", "kt_jvm_library_analysis_test")
+
+package(
+ default_applicable_licenses = ["//:license"],
+ default_testonly = True,
+ default_visibility = ["//tests/jvm/analysis/jvm_library/friends:__subpackages__"],
+)
+
+licenses(["notice"])
+
+kt_jvm_library_analysis_test(
+ name = "no_kt_exported_friend_cross_package_test",
+ expected_friend_jar_names = [],
+ target_under_test = ktfa.kt_jvm_library(
+ name = "no_kt_exported_friend_cross_package",
+ srcs = ["Input.kt"],
+ deps = [
+ # Exports :friend from this package
+ "//tests/jvm/analysis/jvm_library/friends/sub:kt_exports_friend",
+ ],
+ ),
+)
+
+kt_jvm_library_analysis_test(
+ name = "has_java_exported_friend_in_package_test",
+ expected_friend_jar_names = [
+ "libjava_exports_friend-hjar.jar",
+ "libfriend-compile.jar",
+ ],
+ target_under_test = ktfa.kt_jvm_library(
+ name = "has_java_exported_friend_in_package",
+ srcs = ["Input.kt"],
+ deps = [":java_exports_friend"],
+ ),
+)
+
+kt_jvm_library_analysis_test(
+ name = "has_kt_exported_friend_in_package_test",
+ expected_friend_jar_names = [
+ "libkt_exports_friend-compile.jar",
+ "libfriend-compile.jar",
+ ],
+ target_under_test = ktfa.kt_jvm_library(
+ name = "has_kt_exported_friend_in_package",
+ srcs = ["Input.kt"],
+ deps = [":kt_exports_friend"],
+ ),
+)
+
+kt_jvm_library_analysis_test(
+ name = "no_direct_friend_testing_package_test",
+ expected_friend_jar_names = [],
+ target_under_test = ktfa.kt_jvm_library(
+ name = "no_direct_friend_testing_package",
+ srcs = ["Input.kt"],
+ deps = ["//tests/jvm/analysis/jvm_library/friends/testing:testingfriend"],
+ ),
+)
+
+kt_jvm_library_analysis_test(
+ name = "no_direct_friend_subpackage_test",
+ expected_friend_jar_names = [],
+ target_under_test = ktfa.kt_jvm_library(
+ name = "no_direct_friend_subpackage",
+ srcs = ["Input.kt"],
+ deps = ["//tests/jvm/analysis/jvm_library/friends/sub:subfriend"],
+ ),
+)
+
+kt_jvm_library_analysis_test(
+ name = "has_direct_friend_in_package_test",
+ expected_friend_jar_names = ["libfriend-compile.jar"],
+ target_under_test = ktfa.kt_jvm_library(
+ name = "has_direct_friend_in_package",
+ srcs = ["Input.kt"],
+ deps = [":friend"],
+ ),
+)
+
+ktfa.java_library(
+ name = "java_exports_friend",
+ srcs = ["Input.java"],
+ exports = [":friend"],
+)
+
+ktfa.kt_jvm_library(
+ name = "kt_exports_friend",
+ srcs = ["Input.kt"],
+ exports = [":friend"],
+)
+
+ktfa.kt_jvm_library(
+ name = "friend",
+ srcs = ["Input.kt"],
+)
diff --git a/tests/jvm/analysis/jvm_library/friends/Input.java b/tests/jvm/analysis/jvm_library/friends/Input.java
new file mode 100644
index 0000000..5bf1d18
--- /dev/null
+++ b/tests/jvm/analysis/jvm_library/friends/Input.java
@@ -0,0 +1,19 @@
+/*
+ * * Copyright 2022 Google LLC. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package test;
+
+final class Input {}
diff --git a/tests/jvm/analysis/jvm_library/friends/Input.kt b/tests/jvm/analysis/jvm_library/friends/Input.kt
new file mode 100644
index 0000000..b1a99cb
--- /dev/null
+++ b/tests/jvm/analysis/jvm_library/friends/Input.kt
@@ -0,0 +1,17 @@
+/*
+ * * Copyright 2022 Google LLC. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package test
diff --git a/tests/jvm/analysis/jvm_library/friends/sub/BUILD b/tests/jvm/analysis/jvm_library/friends/sub/BUILD
new file mode 100644
index 0000000..7f4a38e
--- /dev/null
+++ b/tests/jvm/analysis/jvm_library/friends/sub/BUILD
@@ -0,0 +1,58 @@
+# Copyright 2022 Google LLC. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the License);
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+load("//kotlin/jvm/testing:for_analysis.bzl", ktfa = "kt_for_analysis")
+load("//kotlin/jvm/testing:jvm_library_analysis_test.bzl", "kt_jvm_library_analysis_test")
+
+package(
+ default_applicable_licenses = ["//:license"],
+ default_testonly = True,
+ default_visibility = ["//tests/jvm/analysis/jvm_library/friends:__subpackages__"],
+)
+
+licenses(["notice"])
+
+kt_jvm_library_analysis_test(
+ name = "no_kt_exported_friend_cross_package_test",
+ expected_friend_jar_names = [
+ "libkt_exports_friend-compile.jar",
+ # Absent # "libfriend-compile.jar"
+ ],
+ target_under_test = ktfa.kt_jvm_library(
+ name = "no_kt_exported_friend_cross_package",
+ srcs = ["Input.kt"],
+ deps = [":kt_exports_friend"],
+ ),
+)
+
+kt_jvm_library_analysis_test(
+ name = "no_direct_friend_cross_package_test",
+ expected_friend_jar_names = [],
+ target_under_test = ktfa.kt_jvm_library(
+ name = "no_direct_friend_cross_package",
+ srcs = ["Input.kt"],
+ deps = ["//tests/jvm/analysis/jvm_library/friends:friend"],
+ ),
+)
+
+ktfa.kt_jvm_library(
+ name = "kt_exports_friend",
+ srcs = ["Input.kt"],
+ exports = ["//tests/jvm/analysis/jvm_library/friends:friend"],
+)
+
+ktfa.kt_jvm_library(
+ name = "subfriend",
+ srcs = ["Input.kt"],
+)
diff --git a/tests/jvm/analysis/jvm_library/friends/sub/Input.kt b/tests/jvm/analysis/jvm_library/friends/sub/Input.kt
new file mode 100644
index 0000000..4c87a1e
--- /dev/null
+++ b/tests/jvm/analysis/jvm_library/friends/sub/Input.kt
@@ -0,0 +1,17 @@
+/*
+ * * Copyright 2022 Google LLC. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package test.sub
diff --git a/tests/jvm/analysis/jvm_library/friends/testing/BUILD b/tests/jvm/analysis/jvm_library/friends/testing/BUILD
new file mode 100644
index 0000000..0ab1bba
--- /dev/null
+++ b/tests/jvm/analysis/jvm_library/friends/testing/BUILD
@@ -0,0 +1,89 @@
+# Copyright 2022 Google LLC. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the License);
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+load("//kotlin/jvm/testing:for_analysis.bzl", ktfa = "kt_for_analysis")
+load("//kotlin/jvm/testing:jvm_library_analysis_test.bzl", "kt_jvm_library_analysis_test")
+
+package(
+ default_applicable_licenses = ["//:license"],
+ default_testonly = True,
+ default_visibility = ["//tests/jvm/analysis/jvm_library/friends:__subpackages__"],
+)
+
+licenses(["notice"])
+
+kt_jvm_library_analysis_test(
+ name = "has_kt_exported_friend_impl_package_test",
+ expected_friend_jar_names = [
+ "libkt_exports_friend-compile.jar",
+ "libfriend-compile.jar",
+ ],
+ target_under_test = ktfa.kt_jvm_library(
+ name = "has_kt_exported_friend_impl_package",
+ srcs = ["Input.kt"],
+ deps = [":kt_exports_friend"],
+ ),
+)
+
+kt_jvm_library_analysis_test(
+ name = "has_direct_friend_impl_package_test",
+ expected_friend_jar_names = [
+ "libfriend-compile.jar",
+ ],
+ target_under_test = ktfa.kt_jvm_library(
+ name = "has_direct_friend_impl_package",
+ srcs = ["Input.kt"],
+ deps = ["//tests/jvm/analysis/jvm_library/friends:friend"],
+ ),
+)
+
+kt_jvm_library_analysis_test(
+ name = "no_kt_exported_friend_sibling_package_test",
+ expected_friend_jar_names = [
+ "libkt_exports_subfriend-compile.jar",
+ # Absent # "subfriend-compile.jar"
+ ],
+ target_under_test = ktfa.kt_jvm_library(
+ name = "no_kt_exported_friend_sibling_package",
+ srcs = ["Input.kt"],
+ deps = [":kt_exports_subfriend"],
+ ),
+)
+
+kt_jvm_library_analysis_test(
+ name = "no_direct_friend_sibling_package_test",
+ expected_friend_jar_names = [],
+ target_under_test = ktfa.kt_jvm_library(
+ name = "no_direct_friend_sibling_package",
+ srcs = ["Input.kt"],
+ deps = ["//tests/jvm/analysis/jvm_library/friends/sub:subfriend"],
+ ),
+)
+
+ktfa.kt_jvm_library(
+ name = "kt_exports_subfriend",
+ srcs = ["Input.kt"],
+ exports = ["//tests/jvm/analysis/jvm_library/friends/sub:subfriend"],
+)
+
+ktfa.kt_jvm_library(
+ name = "kt_exports_friend",
+ srcs = ["Input.kt"],
+ exports = ["//tests/jvm/analysis/jvm_library/friends:friend"],
+)
+
+ktfa.kt_jvm_library(
+ name = "testingfriend",
+ srcs = ["Input.kt"],
+)
diff --git a/tests/jvm/analysis/jvm_library/friends/testing/Input.kt b/tests/jvm/analysis/jvm_library/friends/testing/Input.kt
new file mode 100644
index 0000000..2c65124
--- /dev/null
+++ b/tests/jvm/analysis/jvm_library/friends/testing/Input.kt
@@ -0,0 +1,17 @@
+/*
+ * * Copyright 2022 Google LLC. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package test.testing
diff --git a/tests/jvm/analysis/jvm_library/no_srcs/BUILD b/tests/jvm/analysis/jvm_library/no_srcs/BUILD
new file mode 100644
index 0000000..004d160
--- /dev/null
+++ b/tests/jvm/analysis/jvm_library/no_srcs/BUILD
@@ -0,0 +1,69 @@
+# Copyright 2022 Google LLC. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the License);
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+load("//kotlin/common/testing:testing_rules.bzl", "kt_testing_rules")
+load("//kotlin/jvm/testing:for_analysis.bzl", ktfa = "kt_for_analysis")
+load("//kotlin/jvm/testing:jvm_library_analysis_test.bzl", "kt_jvm_library_analysis_test")
+
+package(
+ default_applicable_licenses = ["//:license"],
+ default_testonly = True,
+)
+
+licenses(["notice"])
+
+kt_testing_rules.assert_failure_test(
+ name = "no_srcs_test",
+ msg_contains = "Expected a source-bearing or an export-oriented target",
+ target_under_test = ktfa.kt_jvm_library(
+ name = "no_srcs",
+ srcs = [],
+ ),
+)
+
+kt_jvm_library_analysis_test(
+ name = "no_srcs_with_exports_test",
+ expect_jdeps = False,
+ required_mnemonic_counts = {"KtAndroidLint": "0"},
+ target_under_test = ktfa.kt_jvm_library(
+ name = "no_srcs_with_exports",
+ srcs = [],
+ exports = [
+ ktfa.kt_jvm_library(
+ name = "no_srcs_with_exports_export",
+ srcs = ["Input.kt"],
+ ),
+ ],
+ ),
+)
+
+kt_jvm_library_analysis_test(
+ name = "only_kt_srcs_test",
+ target_under_test = ktfa.kt_jvm_library(
+ name = "only_kt_srcs",
+ srcs = [
+ "Input.kt",
+ ],
+ ),
+)
+
+kt_jvm_library_analysis_test(
+ name = "only_java_srcs_test",
+ target_under_test = ktfa.kt_jvm_library(
+ name = "only_java_srcs",
+ srcs = [
+ "Input.java",
+ ],
+ ),
+)
diff --git a/tests/jvm/analysis/jvm_library/no_srcs/Input.java b/tests/jvm/analysis/jvm_library/no_srcs/Input.java
new file mode 100644
index 0000000..e675bc1
--- /dev/null
+++ b/tests/jvm/analysis/jvm_library/no_srcs/Input.java
@@ -0,0 +1,16 @@
+/*
+ * * Copyright 2022 Google LLC. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
diff --git a/tests/jvm/analysis/jvm_library/no_srcs/Input.kt b/tests/jvm/analysis/jvm_library/no_srcs/Input.kt
new file mode 100644
index 0000000..963d749
--- /dev/null
+++ b/tests/jvm/analysis/jvm_library/no_srcs/Input.kt
@@ -0,0 +1,17 @@
+/*
+ * * Copyright 2022 Google LLC. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
diff --git a/tests/jvm/analysis/jvm_library/only_common_srcs/BUILD b/tests/jvm/analysis/jvm_library/only_common_srcs/BUILD
new file mode 100644
index 0000000..a91cff7
--- /dev/null
+++ b/tests/jvm/analysis/jvm_library/only_common_srcs/BUILD
@@ -0,0 +1,33 @@
+# Copyright 2022 Google LLC. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the License);
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+load("//kotlin/jvm/testing:for_analysis.bzl", "kt_for_analysis")
+load("//kotlin/jvm/testing:jvm_library_analysis_test.bzl", "kt_jvm_library_analysis_test")
+
+package(
+ default_applicable_licenses = ["//:license"],
+ default_testonly = True,
+)
+
+licenses(["notice"])
+
+kt_jvm_library_analysis_test(
+ name = "only_common_srcs_test",
+ target_under_test = kt_for_analysis.kt_jvm_library(
+ name = "only_common_srcs",
+ common_srcs = [
+ "Input.kt",
+ ],
+ ),
+)
diff --git a/tests/jvm/analysis/jvm_library/only_common_srcs/Input.kt b/tests/jvm/analysis/jvm_library/only_common_srcs/Input.kt
new file mode 100644
index 0000000..963d749
--- /dev/null
+++ b/tests/jvm/analysis/jvm_library/only_common_srcs/Input.kt
@@ -0,0 +1,17 @@
+/*
+ * * Copyright 2022 Google LLC. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
diff --git a/tests/jvm/analysis/jvm_library/plugins/BUILD b/tests/jvm/analysis/jvm_library/plugins/BUILD
new file mode 100644
index 0000000..3694233
--- /dev/null
+++ b/tests/jvm/analysis/jvm_library/plugins/BUILD
@@ -0,0 +1,153 @@
+# Copyright 2022 Google LLC. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the License);
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+load("//kotlin/common/testing:testing_rules.bzl", "kt_testing_rules")
+load("//kotlin/jvm/testing:for_analysis.bzl", ktfa = "kt_for_analysis")
+load("//kotlin/jvm/testing:jvm_library_analysis_test.bzl", "kt_jvm_library_analysis_test")
+
+package(
+ default_applicable_licenses = ["//:license"],
+ default_testonly = True,
+)
+
+licenses(["notice"])
+
+DEFAULT_KOTLINC_PLUGINS = [
+ "jvm-abi-gen.jar",
+]
+
+kt_jvm_library_analysis_test(
+ name = "has_plugin_and_only_kt_srcs_test",
+ expect_processor_classpath = True,
+ expected_exported_processor_classes = [],
+ expected_kotlinc_plugin_jar_names = DEFAULT_KOTLINC_PLUGINS + ["kt_compiler_plugin.jar"],
+ expected_processor_classes = ["java.plugin.class"],
+ target_under_test = ktfa.kt_jvm_library(
+ name = "has_plugin_and_only_kt_srcs",
+ srcs = ["Input.kt"],
+ plugins = [
+ ":java_plugin",
+ ":kt_compiler_plugin",
+ ],
+ ),
+)
+
+kt_jvm_library_analysis_test(
+ name = "has_plugin_and_only_java_srcs_test",
+ expect_processor_classpath = True,
+ expected_exported_processor_classes = [],
+ expected_kotlinc_plugin_jar_names = [], # No kotlinc action
+ expected_processor_classes = ["java.plugin.class"],
+ target_under_test = ktfa.kt_jvm_library(
+ name = "has_plugin_and_only_java_srcs",
+ srcs = ["Input.java"],
+ plugins = [
+ ":java_plugin",
+ ":kt_compiler_plugin",
+ ],
+ ),
+)
+
+kt_jvm_library_analysis_test(
+ name = "has_plugin_without_processor_class_test",
+ expect_processor_classpath = True,
+ expected_exported_processor_classes = [],
+ target_under_test = ktfa.kt_jvm_library(
+ name = "has_plugin_without_processor_class",
+ srcs = ["Input.java"],
+ plugins = [
+ ktfa.java_plugin(
+ name = "java_plugin_without_processor_class",
+ srcs = ["Input.java"],
+ ),
+ ],
+ ),
+)
+
+[
+ kt_jvm_library_analysis_test(
+ name = "dep_on_" + exporter + "_test",
+ expect_processor_classpath = True,
+ expected_kotlinc_plugin_jar_names = DEFAULT_KOTLINC_PLUGINS + ["kt_compiler_plugin.jar"],
+ expected_processor_classes = ["java.plugin.class"],
+ target_under_test = ktfa.kt_jvm_library(
+ name = "dep_on_" + exporter,
+ srcs = ["Input.kt"],
+ deps = [exporter],
+ ),
+ )
+ for exporter in [
+ "java_library_with_exported_plugin",
+ "kt_jvm_library_with_exported_plugin",
+ ] + [
+ "kt_jvm_library_exporting_java_library_with_exported_plugin",
+ "kt_jvm_library_exporting_kt_jvm_library_with_exported_plugin",
+ ]
+]
+
+[
+ kt_jvm_library_analysis_test(
+ name = "kt_jvm_library_exporting_" + export + "_test",
+ expect_processor_classpath = False,
+ expected_exported_processor_classes = ["java.plugin.class"],
+ expected_kotlinc_plugin_jar_names = DEFAULT_KOTLINC_PLUGINS,
+ expected_processor_classes = [],
+ target_under_test = ktfa.kt_jvm_library(
+ name = "kt_jvm_library_exporting_" + export,
+ srcs = ["Input.kt"],
+ exports = [export],
+ ),
+ )
+ for export in [
+ "java_library_with_exported_plugin",
+ "kt_jvm_library_with_exported_plugin",
+ ]
+]
+
+ktfa.java_library(
+ name = "java_library_with_exported_plugin",
+ srcs = ["Input.java"],
+ exported_plugins = [
+ ":java_plugin",
+ ":kt_compiler_plugin",
+ ],
+)
+
+kt_jvm_library_analysis_test(
+ name = "kt_jvm_library_with_exported_plugin_test",
+ expect_processor_classpath = False,
+ expected_exported_processor_classes = ["java.plugin.class"],
+ expected_kotlinc_plugin_jar_names = DEFAULT_KOTLINC_PLUGINS,
+ expected_processor_classes = [], # exported plugin should *not* run on exporter itself
+ target_under_test = ktfa.kt_jvm_library(
+ name = "kt_jvm_library_with_exported_plugin",
+ srcs = ["Input.kt"],
+ exported_plugins = [
+ ":java_plugin",
+ ":kt_compiler_plugin",
+ ],
+ ),
+)
+
+ktfa.java_plugin(
+ name = "java_plugin",
+ srcs = ["Input.java"],
+ processor_class = "java.plugin.class",
+)
+
+ktfa.kt_compiler_plugin(
+ name = "kt_compiler_plugin",
+ jar = kt_testing_rules.create_file(name = "kt_compiler_plugin.jar"),
+ plugin_id = "kt.plugin",
+)
diff --git a/tests/jvm/analysis/jvm_library/plugins/Input.java b/tests/jvm/analysis/jvm_library/plugins/Input.java
new file mode 100644
index 0000000..e675bc1
--- /dev/null
+++ b/tests/jvm/analysis/jvm_library/plugins/Input.java
@@ -0,0 +1,16 @@
+/*
+ * * Copyright 2022 Google LLC. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
diff --git a/tests/jvm/analysis/jvm_library/plugins/Input.kt b/tests/jvm/analysis/jvm_library/plugins/Input.kt
new file mode 100644
index 0000000..963d749
--- /dev/null
+++ b/tests/jvm/analysis/jvm_library/plugins/Input.kt
@@ -0,0 +1,17 @@
+/*
+ * * Copyright 2022 Google LLC. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
diff --git a/tests/jvm/analysis/jvm_library/resources/BUILD b/tests/jvm/analysis/jvm_library/resources/BUILD
new file mode 100644
index 0000000..1c4797f
--- /dev/null
+++ b/tests/jvm/analysis/jvm_library/resources/BUILD
@@ -0,0 +1,32 @@
+# Copyright 2022 Google LLC. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the License);
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+load("//kotlin/jvm/testing:for_analysis.bzl", ktfa = "kt_for_analysis")
+load("//kotlin/jvm/testing:jvm_library_analysis_test.bzl", "kt_jvm_library_analysis_test")
+
+package(
+ default_applicable_licenses = ["//:license"],
+ default_testonly = True,
+)
+
+licenses(["notice"])
+
+kt_jvm_library_analysis_test(
+ name = "has_resources_test",
+ target_under_test = ktfa.kt_jvm_library(
+ name = "has_resources",
+ srcs = ["Input.kt"],
+ resources = ["resource.txt"],
+ ),
+)
diff --git a/tests/jvm/analysis/jvm_library/resources/Input.kt b/tests/jvm/analysis/jvm_library/resources/Input.kt
new file mode 100644
index 0000000..963d749
--- /dev/null
+++ b/tests/jvm/analysis/jvm_library/resources/Input.kt
@@ -0,0 +1,17 @@
+/*
+ * * Copyright 2022 Google LLC. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
diff --git a/tests/jvm/analysis/jvm_library/resources/resource.txt b/tests/jvm/analysis/jvm_library/resources/resource.txt
new file mode 100644
index 0000000..b986da2
--- /dev/null
+++ b/tests/jvm/analysis/jvm_library/resources/resource.txt
@@ -0,0 +1,14 @@
+# Copyright 2022 Google LLC. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the License);
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
diff --git a/tests/jvm/analysis/jvm_library/runtime_deps/BUILD b/tests/jvm/analysis/jvm_library/runtime_deps/BUILD
new file mode 100644
index 0000000..aaea117
--- /dev/null
+++ b/tests/jvm/analysis/jvm_library/runtime_deps/BUILD
@@ -0,0 +1,41 @@
+# Copyright 2022 Google LLC. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the License);
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+load("//kotlin/jvm/testing:for_analysis.bzl", "kt_for_analysis")
+load("//kotlin/jvm/testing:jvm_library_analysis_test.bzl", "kt_jvm_library_analysis_test")
+
+package(
+ default_applicable_licenses = ["//:license"],
+ default_testonly = True,
+)
+
+licenses(["notice"])
+
+kt_for_analysis.java_library(
+ name = "runtime_deps_test_dep",
+ srcs = [],
+)
+
+kt_jvm_library_analysis_test(
+ name = "runtime_deps_test",
+ target_under_test = kt_for_analysis.kt_jvm_library(
+ name = "runtime_deps",
+ srcs = [
+ "Input.kt",
+ ],
+ runtime_deps = [
+ ":runtime_deps_test_dep",
+ ],
+ ),
+)
diff --git a/tests/jvm/analysis/jvm_library/runtime_deps/Input.java b/tests/jvm/analysis/jvm_library/runtime_deps/Input.java
new file mode 100644
index 0000000..e675bc1
--- /dev/null
+++ b/tests/jvm/analysis/jvm_library/runtime_deps/Input.java
@@ -0,0 +1,16 @@
+/*
+ * * Copyright 2022 Google LLC. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
diff --git a/tests/jvm/analysis/jvm_library/runtime_deps/Input.kt b/tests/jvm/analysis/jvm_library/runtime_deps/Input.kt
new file mode 100644
index 0000000..963d749
--- /dev/null
+++ b/tests/jvm/analysis/jvm_library/runtime_deps/Input.kt
@@ -0,0 +1,17 @@
+/*
+ * * Copyright 2022 Google LLC. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
diff --git a/tests/jvm/analysis/jvm_library/treeartifacts_srcs/BUILD b/tests/jvm/analysis/jvm_library/treeartifacts_srcs/BUILD
new file mode 100644
index 0000000..6151a43
--- /dev/null
+++ b/tests/jvm/analysis/jvm_library/treeartifacts_srcs/BUILD
@@ -0,0 +1,106 @@
+# Copyright 2022 Google LLC. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the License);
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+load("//kotlin/common/testing:testing_rules.bzl", "kt_testing_rules")
+load("//kotlin/jvm/testing:for_analysis.bzl", ktfa = "kt_for_analysis")
+load("//kotlin/jvm/testing:jvm_library_analysis_test.bzl", "kt_jvm_library_analysis_test")
+
+package(
+ default_applicable_licenses = ["//:license"],
+ default_testonly = True,
+)
+
+licenses(["notice"])
+
+kt_jvm_library_analysis_test(
+ name = "treeartifact_basename_kotlin_test",
+ target_under_test = ktfa.kt_jvm_library(
+ name = "treeartifact_basename_kotlin",
+ srcs = [
+ kt_testing_rules.create_dir(
+ name = "treeartifact_extension/kotlin",
+ srcs = [
+ "Input.java", # TODO: Reject this source
+ ],
+ ),
+ ],
+ ),
+)
+
+kt_jvm_library_analysis_test(
+ name = "treeartifact_basename_java_test",
+ target_under_test = ktfa.kt_jvm_library(
+ name = "treeartifact_basename_java",
+ srcs = [
+ kt_testing_rules.create_dir(
+ name = "treeartifact_extension/java",
+ srcs = [
+ "Input.kt", # TODO: Reject this source
+ ],
+ ),
+ ],
+ ),
+)
+
+kt_testing_rules.assert_failure_test(
+ name = "treeartifact_extension_kt_test",
+ msg_contains = "/treeartifact_extension.kt",
+ target_under_test = ktfa.kt_jvm_library(
+ name = "treeartifact_extension_kt",
+ srcs = [
+ kt_testing_rules.create_dir(
+ name = "treeartifact_extension.kt",
+ ),
+ ],
+ ),
+)
+
+kt_testing_rules.assert_failure_test(
+ name = "treeartifact_extension_java_test",
+ msg_contains = "/treeartifact_extension.java",
+ target_under_test = ktfa.kt_jvm_library(
+ name = "treeartifact_extension_java",
+ srcs = [
+ kt_testing_rules.create_dir(
+ name = "treeartifact_extension.java",
+ ),
+ ],
+ ),
+)
+
+kt_testing_rules.assert_failure_test(
+ name = "treeartifact_extension_srcjar_test",
+ msg_contains = "/treeartifact_extension.srcjar",
+ target_under_test = ktfa.kt_jvm_library(
+ name = "treeartifact_extension_srcjar",
+ srcs = [
+ kt_testing_rules.create_dir(
+ name = "treeartifact_extension.srcjar",
+ ),
+ ],
+ ),
+)
+
+kt_testing_rules.assert_failure_test(
+ name = "treeartifact_no_extension_test",
+ msg_contains = "/treeartifact_no_extension",
+ target_under_test = ktfa.kt_jvm_library(
+ name = "treeartifact_no_extension",
+ srcs = [
+ kt_testing_rules.create_dir(
+ name = "treeartifact_no_extension_dir",
+ ),
+ ],
+ ),
+)
diff --git a/tests/jvm/analysis/jvm_library/treeartifacts_srcs/Input.java b/tests/jvm/analysis/jvm_library/treeartifacts_srcs/Input.java
new file mode 100644
index 0000000..e675bc1
--- /dev/null
+++ b/tests/jvm/analysis/jvm_library/treeartifacts_srcs/Input.java
@@ -0,0 +1,16 @@
+/*
+ * * Copyright 2022 Google LLC. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
diff --git a/tests/jvm/analysis/jvm_library/treeartifacts_srcs/Input.kt b/tests/jvm/analysis/jvm_library/treeartifacts_srcs/Input.kt
new file mode 100644
index 0000000..963d749
--- /dev/null
+++ b/tests/jvm/analysis/jvm_library/treeartifacts_srcs/Input.kt
@@ -0,0 +1,17 @@
+/*
+ * * Copyright 2022 Google LLC. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
diff --git a/tests/jvm/analysis/util/file_factory/BUILD b/tests/jvm/analysis/util/file_factory/BUILD
new file mode 100644
index 0000000..3a0b592
--- /dev/null
+++ b/tests/jvm/analysis/util/file_factory/BUILD
@@ -0,0 +1,25 @@
+# Copyright 2022 Google LLC. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the License);
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+load(":unittests.bzl", "unittests")
+
+package(
+ default_testonly = True,
+)
+
+licenses(["notice"])
+
+unittests.render(
+ name = "unittests",
+)
diff --git a/tests/jvm/analysis/util/file_factory/unittests.bzl b/tests/jvm/analysis/util/file_factory/unittests.bzl
new file mode 100644
index 0000000..cf7a2a4
--- /dev/null
+++ b/tests/jvm/analysis/util/file_factory/unittests.bzl
@@ -0,0 +1,85 @@
+# Copyright 2022 Google LLC. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the License);
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""unittests"""
+
+load("//:visibility.bzl", "RULES_KOTLIN")
+load("//kotlin/common/testing:unittest_suites.bzl", "kt_unittest_suites")
+load("//kotlin/jvm/util:file_factory.bzl", "FileFactory")
+load("@bazel_skylib//lib:unittest.bzl", "asserts")
+
+visibility(RULES_KOTLIN)
+
+unittests = kt_unittest_suites.create()
+
+def _base_from_file(ctx, env):
+ base_file = ctx.actions.declare_file("file/base.txt")
+ factory = FileFactory(ctx, base_file)
+
+ _assert_path_equals(ctx, env, "/file/base", factory.base_as_path)
+
+ return [base_file]
+
+unittests.expect_finish(_base_from_file)
+
+def _declare(ctx, env):
+ factory = FileFactory(ctx, "string/base")
+
+ _assert_path_equals(ctx, env, "/string/base", factory.base_as_path)
+
+ a_file = factory.declare_file("a.txt")
+ _assert_path_equals(ctx, env, "/string/basea.txt", a_file.path)
+
+ b_dir = factory.declare_directory("b_dir")
+ _assert_path_equals(ctx, env, "/string/baseb_dir", b_dir.path)
+
+ return [a_file, b_dir]
+
+unittests.expect_finish(_declare)
+
+def _derive(ctx, env):
+ factory = FileFactory(ctx, "")
+
+ # Once
+ factory_once = factory.derive("once")
+ _assert_path_equals(ctx, env, "/once", factory_once.base_as_path)
+
+ # Twice
+ factory_twice = factory_once.derive("/twice")
+ _assert_path_equals(ctx, env, "/once/twice", factory_twice.base_as_path)
+
+unittests.expect_finish(_derive)
+
+def _base_file_without_extension(ctx):
+ base_file = ctx.actions.declare_file(ctx.label.name + "/BUILD")
+ FileFactory(ctx, base_file)
+
+unittests.expect_fail(_base_file_without_extension, "file must have an extension")
+
+def _base_file_from_different_pkg(ctx):
+ mock_file = struct(owner = struct(package = ctx.label.package + "/sub"), extension = "txt")
+ FileFactory(ctx, mock_file)
+
+unittests.expect_fail(_base_file_from_different_pkg, "file must be from ctx package")
+
+def _assert_path_equals(ctx, env, expected, actual):
+ pkg_path = ctx.bin_dir.path + "/" + ctx.label.package
+
+ asserts.equals(
+ env,
+ pkg_path + expected,
+ actual,
+ )
+
+_test, _fail = unittests.close() # @unused
diff --git a/tests/jvm/java/neverlink/BUILD b/tests/jvm/java/neverlink/BUILD
index c6daa08..a25ac73 100644
--- a/tests/jvm/java/neverlink/BUILD
+++ b/tests/jvm/java/neverlink/BUILD
@@ -12,15 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-load("//tests/analysis:for_test.bzl", "rules_for_test")
-load("//tests/analysis:jvm_library_test.bzl", "jvm_library_test")
+load("//kotlin/jvm/testing:for_analysis.bzl", "kt_for_analysis")
+load("//kotlin/jvm/testing:jvm_library_analysis_test.bzl", "kt_jvm_library_analysis_test")
licenses(["notice"])
-jvm_library_test(
+kt_jvm_library_analysis_test(
name = "neverlinked_input_library_test",
expect_neverlink = True,
- target_under_test = rules_for_test.kt_jvm_library(
+ target_under_test = kt_for_analysis.kt_jvm_library(
name = "neverlinked_input_library",
srcs = ["Input.kt"],
neverlink = True,
diff --git a/tests/jvm/java/srcartifacts/BUILD b/tests/jvm/java/srcartifacts/BUILD
index 9d51c82..e974d73 100644
--- a/tests/jvm/java/srcartifacts/BUILD
+++ b/tests/jvm/java/srcartifacts/BUILD
@@ -13,10 +13,11 @@
# limitations under the License.
load("//kotlin:rules.bzl", "kt_jvm_library", "kt_jvm_test")
-load("//tests/analysis:util.bzl", "create_dir", "create_file")
+load("//kotlin/common/testing:testing_rules.bzl", "kt_testing_rules")
load("@bazel_skylib//rules:build_test.bzl", "build_test")
package(
+ default_applicable_licenses = ["//:license"],
default_testonly = 1,
)
@@ -43,7 +44,7 @@ kt_jvm_test(
],
)
-create_dir(
+kt_testing_rules.create_dir(
name = "dir/java",
srcs = [
"JavaInJavaDir.java",
@@ -51,7 +52,7 @@ create_dir(
subdir = "srcartifacts",
)
-create_dir(
+kt_testing_rules.create_dir(
name = "dir/kotlin",
srcs = [
"KtInKotlinDir.kt",
@@ -59,16 +60,16 @@ create_dir(
subdir = "srcartifacts",
)
-create_dir(
+kt_testing_rules.create_dir(
name = "dir/empty",
srcs = [],
subdir = "srcartifacts/empty",
)
-create_dir(
+kt_testing_rules.create_dir(
name = "dir/resources",
srcs = [
- create_file(
+ kt_testing_rules.create_file(
name = "resources_in_resources_dir.txt",
content = "Test resource content.",
),
@@ -92,7 +93,7 @@ java_library(
kt_jvm_library(
name = "empty_java_tree_artifact",
srcs = [
- create_dir(
+ kt_testing_rules.create_dir(
name = "dir/empty_java/java",
srcs = [],
subdir = "srcartifacts",
@@ -103,7 +104,7 @@ kt_jvm_library(
kt_jvm_library(
name = "empty_kotlin_tree_artifact",
srcs = [
- create_dir(
+ kt_testing_rules.create_dir(
name = "dir/empty_kotlin/kotlin",
srcs = [],
subdir = "srcartifacts",