Migrate Dagger's javatests/dagger/functional/multipackage/ tests to Kotlin sources.
RELNOTES=N/A
PiperOrigin-RevId: 504298575
diff --git a/javatests/dagger/functional/kotlinsrc/multipackage/BUILD b/javatests/dagger/functional/kotlinsrc/multipackage/BUILD
new file mode 100644
index 0000000..d48ec82
--- /dev/null
+++ b/javatests/dagger/functional/kotlinsrc/multipackage/BUILD
@@ -0,0 +1,52 @@
+# Copyright (C) 2023 The Dagger Authors.
+#
+# 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.
+
+# Description:
+# Functional tests for Dagger multipackage usages.
+
+load(
+ "//:build_defs.bzl",
+ "DOCLINT_HTML_AND_SYNTAX",
+ "DOCLINT_REFERENCES",
+)
+load("//:test_defs.bzl", "GenKtTests")
+
+package(default_visibility = ["//:src"])
+
+# Looks like Dagger's strict deps exemption isn't working properly in Bazel
+# so we need to expose transitive deps?
+TRANSITIVE_DEPS = [
+ "//javatests/dagger/functional/kotlinsrc/multipackage/b",
+ "//javatests/dagger/functional/kotlinsrc/multipackage/c",
+ "//javatests/dagger/functional/kotlinsrc/multipackage/d",
+ "//javatests/dagger/functional/kotlinsrc/multipackage/foo",
+ "//javatests/dagger/functional/kotlinsrc/multipackage/grandsub",
+]
+
+GenKtTests(
+ name = "multipackage",
+ srcs = glob(["*.kt"]),
+ gen_library_deps = TRANSITIVE_DEPS + [
+ "//javatests/dagger/functional/kotlinsrc/multipackage/a",
+ "//javatests/dagger/functional/kotlinsrc/multipackage/moduleconstructor",
+ "//javatests/dagger/functional/kotlinsrc/multipackage/primitives",
+ "//javatests/dagger/functional/kotlinsrc/multipackage/sub",
+ ],
+ javacopts = DOCLINT_HTML_AND_SYNTAX + DOCLINT_REFERENCES,
+ deps = [
+ "//:dagger_with_compiler",
+ "//third_party/java/junit",
+ "//third_party/java/truth",
+ ],
+)
diff --git a/javatests/dagger/functional/kotlinsrc/multipackage/FooComponent.kt b/javatests/dagger/functional/kotlinsrc/multipackage/FooComponent.kt
new file mode 100644
index 0000000..ad79578
--- /dev/null
+++ b/javatests/dagger/functional/kotlinsrc/multipackage/FooComponent.kt
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2023 The Dagger Authors.
+ *
+ * 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 dagger.functional.kotlinsrc.multipackage
+
+import dagger.Component
+import dagger.functional.kotlinsrc.multipackage.a.AModule
+import dagger.functional.kotlinsrc.multipackage.a.UsesInaccessible
+import dagger.functional.kotlinsrc.multipackage.a.UsesInaccessibleInGenericsOnly
+import dagger.functional.kotlinsrc.multipackage.sub.FooChildComponent
+
+/**
+ * A component that tests the interaction between subcomponents, multiple packages, and
+ * multibindings. Specifically, we want:
+ * * A set binding with some contributions in the parent component, and some in the subcomponent.
+ * * The contributions come from different packages, but not the package of either component.
+ * * The set binding is requested in the subcomponent through a binding from a separate package.
+ * * No binding in the subcomponent, that's in the subcomponent's package, directly uses any binding
+ * from the component's package.
+ */
+// NOTE(beder): Be careful about changing any bindings in either this component or the subcomponent.
+// Even adding a binding might stop this test from testing what it's supposed to test.
+@Component(modules = [AModule::class])
+internal interface FooComponent {
+ fun setOfString(): Set<String>
+ fun fooChildComponent(): FooChildComponent
+ fun usesInaccessible(): UsesInaccessible
+ fun accessibleConstructorUsesInaccessibleInGenericsOnly(): UsesInaccessibleInGenericsOnly
+}
diff --git a/javatests/dagger/functional/kotlinsrc/multipackage/FooComponentTest.kt b/javatests/dagger/functional/kotlinsrc/multipackage/FooComponentTest.kt
new file mode 100644
index 0000000..c2dabff
--- /dev/null
+++ b/javatests/dagger/functional/kotlinsrc/multipackage/FooComponentTest.kt
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2023 The Dagger Authors.
+ *
+ * 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 dagger.functional.kotlinsrc.multipackage
+
+import com.google.common.truth.Truth.assertThat
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+
+@RunWith(JUnit4::class)
+class FooComponentTest {
+ @Test
+ fun buildTest() {
+ assertThat(DaggerFooComponent.create()).isNotNull()
+ }
+}
diff --git a/javatests/dagger/functional/kotlinsrc/multipackage/MultibindsComponent.kt b/javatests/dagger/functional/kotlinsrc/multipackage/MultibindsComponent.kt
new file mode 100644
index 0000000..45e3c31
--- /dev/null
+++ b/javatests/dagger/functional/kotlinsrc/multipackage/MultibindsComponent.kt
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2023 The Dagger Authors.
+ *
+ * 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 dagger.functional.kotlinsrc.multipackage
+
+import dagger.Component
+import dagger.functional.kotlinsrc.multipackage.a.AMultibindsModule
+import dagger.functional.kotlinsrc.multipackage.a.UsesInaccessible
+
+/**
+ * A component that tests the interaction between multiple packages and `@Multibinding`s.
+ * Specifically, we want:
+ * * A `@Multibinding` for an empty set of a type not accessible from this package.
+ * * A `@Multibinding` for an empty map of a type not accessible from this package.
+ * * A public type that injects the empty set and map of inaccessible objects.
+ */
+@Component(modules = [AMultibindsModule::class])
+internal interface MultibindsComponent {
+ fun usesInaccessible(): UsesInaccessible
+}
diff --git a/javatests/dagger/functional/kotlinsrc/multipackage/PrimitivesAcrossPackagesComponent.kt b/javatests/dagger/functional/kotlinsrc/multipackage/PrimitivesAcrossPackagesComponent.kt
new file mode 100644
index 0000000..8fdaec1
--- /dev/null
+++ b/javatests/dagger/functional/kotlinsrc/multipackage/PrimitivesAcrossPackagesComponent.kt
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2023 The Dagger Authors.
+ *
+ * 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 dagger.functional.kotlinsrc.multipackage
+
+import dagger.Component
+import dagger.functional.kotlinsrc.multipackage.primitives.PrimitiveAcrossPackagesModule
+import javax.inject.Provider
+
+// b/77150738#comment11
+@Component(modules = [PrimitiveAcrossPackagesModule::class])
+internal interface PrimitivesAcrossPackagesComponent {
+ fun primitive(): Boolean
+ fun boxedPrimitive(): Provider<Boolean>
+}
diff --git a/javatests/dagger/functional/kotlinsrc/multipackage/UsesModuleWithInaccessibleConstructor.kt b/javatests/dagger/functional/kotlinsrc/multipackage/UsesModuleWithInaccessibleConstructor.kt
new file mode 100644
index 0000000..85407d5
--- /dev/null
+++ b/javatests/dagger/functional/kotlinsrc/multipackage/UsesModuleWithInaccessibleConstructor.kt
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2023 The Dagger Authors.
+ *
+ * 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 dagger.functional.kotlinsrc.multipackage
+
+import dagger.Component
+import dagger.functional.kotlinsrc.multipackage.moduleconstructor.ModuleWithInaccessibleConstructor
+
+@Component(modules = [ModuleWithInaccessibleConstructor::class])
+interface UsesModuleWithInaccessibleConstructor {
+ fun i(): Int
+}
diff --git a/javatests/dagger/functional/kotlinsrc/multipackage/a/AModule.kt b/javatests/dagger/functional/kotlinsrc/multipackage/a/AModule.kt
new file mode 100644
index 0000000..c4fc7f8
--- /dev/null
+++ b/javatests/dagger/functional/kotlinsrc/multipackage/a/AModule.kt
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2023 The Dagger Authors.
+ *
+ * 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 dagger.functional.kotlinsrc.multipackage.a
+
+import dagger.Binds
+import dagger.Module
+import dagger.Provides
+import dagger.multibindings.ElementsIntoSet
+import dagger.multibindings.IntoMap
+import dagger.multibindings.IntoSet
+import dagger.multibindings.StringKey
+
+@Module
+abstract class AModule {
+ @Binds
+ @IntoSet
+ internal abstract fun provideInaccessible(inaccessible: Inaccessible): Inaccessible
+
+ @Binds
+ @IntoMap
+ @StringKey("inaccessible")
+ internal abstract fun provideInaccessibleToMap(inaccessible: Inaccessible): Inaccessible
+
+ companion object {
+ @Provides @IntoSet fun provideString(): String = "a"
+
+ @Provides
+ @ElementsIntoSet
+ internal fun provideSetOfInaccessibles(): Set<Inaccessible> = hashSetOf()
+ }
+}
diff --git a/javatests/dagger/functional/kotlinsrc/multipackage/a/AMultibindsModule.kt b/javatests/dagger/functional/kotlinsrc/multipackage/a/AMultibindsModule.kt
new file mode 100644
index 0000000..16f822f
--- /dev/null
+++ b/javatests/dagger/functional/kotlinsrc/multipackage/a/AMultibindsModule.kt
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2023 The Dagger Authors.
+ *
+ * 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 dagger.functional.kotlinsrc.multipackage.a
+
+import dagger.Module
+import dagger.multibindings.Multibinds
+
+/** A module that `@Multibinds` a set and a map of [Inaccessible]. */
+@Module
+abstract class AMultibindsModule {
+ @Multibinds internal abstract fun inaccessibleSet(): Set<Inaccessible>
+
+ @Multibinds internal abstract fun inaccessibleMap(): Map<String, Inaccessible>
+}
diff --git a/javatests/dagger/functional/kotlinsrc/multipackage/a/BUILD b/javatests/dagger/functional/kotlinsrc/multipackage/a/BUILD
new file mode 100644
index 0000000..091fe1a
--- /dev/null
+++ b/javatests/dagger/functional/kotlinsrc/multipackage/a/BUILD
@@ -0,0 +1,34 @@
+# Copyright (C) 2023 The Dagger Authors.
+#
+# 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.
+
+# Description:
+# Functional tests for Dagger multipackage usages.
+
+load(
+ "//:build_defs.bzl",
+ "DOCLINT_HTML_AND_SYNTAX",
+ "DOCLINT_REFERENCES",
+)
+load("//:test_defs.bzl", "GenKtLibrary")
+
+package(default_visibility = ["//:src"])
+
+GenKtLibrary(
+ name = "a",
+ srcs = glob(["*.kt"]),
+ javacopts = DOCLINT_HTML_AND_SYNTAX + DOCLINT_REFERENCES,
+ deps = [
+ "//:dagger_with_compiler",
+ ],
+)
diff --git a/javatests/dagger/functional/kotlinsrc/multipackage/a/Inaccessible.kt b/javatests/dagger/functional/kotlinsrc/multipackage/a/Inaccessible.kt
new file mode 100644
index 0000000..08c04e2
--- /dev/null
+++ b/javatests/dagger/functional/kotlinsrc/multipackage/a/Inaccessible.kt
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2023 The Dagger Authors.
+ *
+ * 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 dagger.functional.kotlinsrc.multipackage.a
+
+import javax.inject.Inject
+
+internal class Inaccessible @Inject constructor()
diff --git a/javatests/dagger/functional/kotlinsrc/multipackage/a/InaccessibleGeneric.kt b/javatests/dagger/functional/kotlinsrc/multipackage/a/InaccessibleGeneric.kt
new file mode 100644
index 0000000..85ce564
--- /dev/null
+++ b/javatests/dagger/functional/kotlinsrc/multipackage/a/InaccessibleGeneric.kt
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2023 The Dagger Authors.
+ *
+ * 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 dagger.functional.kotlinsrc.multipackage.a
+
+import javax.inject.Inject
+
+internal class InaccessibleGeneric<T> @Inject constructor()
diff --git a/javatests/dagger/functional/kotlinsrc/multipackage/a/UsesInaccessible.kt b/javatests/dagger/functional/kotlinsrc/multipackage/a/UsesInaccessible.kt
new file mode 100644
index 0000000..b5bf34d
--- /dev/null
+++ b/javatests/dagger/functional/kotlinsrc/multipackage/a/UsesInaccessible.kt
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2023 The Dagger Authors.
+ *
+ * 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 dagger.functional.kotlinsrc.multipackage.a
+
+import javax.inject.Inject
+
+class UsesInaccessible
+@Inject
+internal constructor(
+ @Suppress("UNUSED_PARAMETER") inaccessible: Inaccessible,
+ @Suppress("UNUSED_PARAMETER") inaccessibleSet: Set<Inaccessible>,
+ @Suppress("UNUSED_PARAMETER") inaccessibleMap: Map<String, Inaccessible>,
+ @Suppress("UNUSED_PARAMETER") inaccessibleGeneric: InaccessibleGeneric<Int>
+)
diff --git a/javatests/dagger/functional/kotlinsrc/multipackage/a/UsesInaccessibleInGenericsOnly.kt b/javatests/dagger/functional/kotlinsrc/multipackage/a/UsesInaccessibleInGenericsOnly.kt
new file mode 100644
index 0000000..01b3b94
--- /dev/null
+++ b/javatests/dagger/functional/kotlinsrc/multipackage/a/UsesInaccessibleInGenericsOnly.kt
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2023 The Dagger Authors.
+ *
+ * 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 dagger.functional.kotlinsrc.multipackage.a
+
+import javax.inject.Inject
+
+class UsesInaccessibleInGenericsOnly
+@Inject
+internal constructor(
+ @Suppress("UNUSED_PARAMETER") inaccessibleSet: Set<Inaccessible>,
+ @Suppress("UNUSED_PARAMETER") inaccessibleMap: Map<String, Inaccessible>
+)
diff --git a/javatests/dagger/functional/kotlinsrc/multipackage/b/BModule.kt b/javatests/dagger/functional/kotlinsrc/multipackage/b/BModule.kt
new file mode 100644
index 0000000..60f7a7f
--- /dev/null
+++ b/javatests/dagger/functional/kotlinsrc/multipackage/b/BModule.kt
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2023 The Dagger Authors.
+ *
+ * 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 dagger.functional.kotlinsrc.multipackage.b
+
+import dagger.Module
+import dagger.Provides
+import dagger.multibindings.IntoSet
+
+@Module
+object BModule {
+ @Provides @IntoSet fun provideString(): String = "b"
+}
diff --git a/javatests/dagger/functional/kotlinsrc/multipackage/b/BUILD b/javatests/dagger/functional/kotlinsrc/multipackage/b/BUILD
new file mode 100644
index 0000000..a400acd
--- /dev/null
+++ b/javatests/dagger/functional/kotlinsrc/multipackage/b/BUILD
@@ -0,0 +1,34 @@
+# Copyright (C) 2023 The Dagger Authors.
+#
+# 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.
+
+# Description:
+# Functional tests for Dagger multipackage usages.
+
+load(
+ "//:build_defs.bzl",
+ "DOCLINT_HTML_AND_SYNTAX",
+ "DOCLINT_REFERENCES",
+)
+load("//:test_defs.bzl", "GenKtLibrary")
+
+package(default_visibility = ["//:src"])
+
+GenKtLibrary(
+ name = "b",
+ srcs = glob(["*.kt"]),
+ javacopts = DOCLINT_HTML_AND_SYNTAX + DOCLINT_REFERENCES,
+ deps = [
+ "//:dagger_with_compiler",
+ ],
+)
diff --git a/javatests/dagger/functional/kotlinsrc/multipackage/c/BUILD b/javatests/dagger/functional/kotlinsrc/multipackage/c/BUILD
new file mode 100644
index 0000000..1e5938a
--- /dev/null
+++ b/javatests/dagger/functional/kotlinsrc/multipackage/c/BUILD
@@ -0,0 +1,34 @@
+# Copyright (C) 2023 The Dagger Authors.
+#
+# 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.
+
+# Description:
+# Functional tests for Dagger multipackage usages.
+
+load(
+ "//:build_defs.bzl",
+ "DOCLINT_HTML_AND_SYNTAX",
+ "DOCLINT_REFERENCES",
+)
+load("//:test_defs.bzl", "GenKtLibrary")
+
+package(default_visibility = ["//:src"])
+
+GenKtLibrary(
+ name = "c",
+ srcs = glob(["*.kt"]),
+ javacopts = DOCLINT_HTML_AND_SYNTAX + DOCLINT_REFERENCES,
+ deps = [
+ "//:dagger_with_compiler",
+ ],
+)
diff --git a/javatests/dagger/functional/kotlinsrc/multipackage/c/CModule.kt b/javatests/dagger/functional/kotlinsrc/multipackage/c/CModule.kt
new file mode 100644
index 0000000..54a11e4
--- /dev/null
+++ b/javatests/dagger/functional/kotlinsrc/multipackage/c/CModule.kt
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2023 The Dagger Authors.
+ *
+ * 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 dagger.functional.kotlinsrc.multipackage.c
+
+import dagger.Module
+import dagger.Provides
+import dagger.multibindings.IntoSet
+
+@Module
+object CModule {
+ @Provides @IntoSet fun provideString(): String = "c"
+}
diff --git a/javatests/dagger/functional/kotlinsrc/multipackage/d/BUILD b/javatests/dagger/functional/kotlinsrc/multipackage/d/BUILD
new file mode 100644
index 0000000..1ea9304
--- /dev/null
+++ b/javatests/dagger/functional/kotlinsrc/multipackage/d/BUILD
@@ -0,0 +1,34 @@
+# Copyright (C) 2023 The Dagger Authors.
+#
+# 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.
+
+# Description:
+# Functional tests for Dagger multipackage usages.
+
+load(
+ "//:build_defs.bzl",
+ "DOCLINT_HTML_AND_SYNTAX",
+ "DOCLINT_REFERENCES",
+)
+load("//:test_defs.bzl", "GenKtLibrary")
+
+package(default_visibility = ["//:src"])
+
+GenKtLibrary(
+ name = "d",
+ srcs = glob(["*.kt"]),
+ javacopts = DOCLINT_HTML_AND_SYNTAX + DOCLINT_REFERENCES,
+ deps = [
+ "//:dagger_with_compiler",
+ ],
+)
diff --git a/javatests/dagger/functional/kotlinsrc/multipackage/d/DModule.kt b/javatests/dagger/functional/kotlinsrc/multipackage/d/DModule.kt
new file mode 100644
index 0000000..2840db9
--- /dev/null
+++ b/javatests/dagger/functional/kotlinsrc/multipackage/d/DModule.kt
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2023 The Dagger Authors.
+ *
+ * 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 dagger.functional.kotlinsrc.multipackage.d
+
+import dagger.Module
+import dagger.Provides
+import dagger.multibindings.IntoSet
+
+@Module
+object DModule {
+ @Provides @IntoSet fun provideString(): String = "d"
+}
diff --git a/javatests/dagger/functional/kotlinsrc/multipackage/foo/BUILD b/javatests/dagger/functional/kotlinsrc/multipackage/foo/BUILD
new file mode 100644
index 0000000..c17413f
--- /dev/null
+++ b/javatests/dagger/functional/kotlinsrc/multipackage/foo/BUILD
@@ -0,0 +1,34 @@
+# Copyright (C) 2023 The Dagger Authors.
+#
+# 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.
+
+# Description:
+# Functional tests for Dagger multipackage usages.
+
+load(
+ "//:build_defs.bzl",
+ "DOCLINT_HTML_AND_SYNTAX",
+ "DOCLINT_REFERENCES",
+)
+load("//:test_defs.bzl", "GenKtLibrary")
+
+package(default_visibility = ["//:src"])
+
+GenKtLibrary(
+ name = "foo",
+ srcs = glob(["*.kt"]),
+ javacopts = DOCLINT_HTML_AND_SYNTAX + DOCLINT_REFERENCES,
+ deps = [
+ "//:dagger_with_compiler",
+ ],
+)
diff --git a/javatests/dagger/functional/kotlinsrc/multipackage/foo/Foo.kt b/javatests/dagger/functional/kotlinsrc/multipackage/foo/Foo.kt
new file mode 100644
index 0000000..4fb925a
--- /dev/null
+++ b/javatests/dagger/functional/kotlinsrc/multipackage/foo/Foo.kt
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2023 The Dagger Authors.
+ *
+ * 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 dagger.functional.kotlinsrc.multipackage.foo
+
+import javax.inject.Inject
+
+class Foo<T> @Inject internal constructor(val strings: Set<String>)
diff --git a/javatests/dagger/functional/kotlinsrc/multipackage/grandsub/BUILD b/javatests/dagger/functional/kotlinsrc/multipackage/grandsub/BUILD
new file mode 100644
index 0000000..7e3cb13
--- /dev/null
+++ b/javatests/dagger/functional/kotlinsrc/multipackage/grandsub/BUILD
@@ -0,0 +1,38 @@
+# Copyright (C) 2023 The Dagger Authors.
+#
+# 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.
+
+# Description:
+# Functional tests for Dagger multipackage usages.
+
+load(
+ "//:build_defs.bzl",
+ "DOCLINT_HTML_AND_SYNTAX",
+ "DOCLINT_REFERENCES",
+)
+load("//:test_defs.bzl", "GenKtLibrary")
+
+package(default_visibility = ["//:src"])
+
+GenKtLibrary(
+ name = "grandsub",
+ srcs = glob(["*.kt"]),
+ gen_library_deps = [
+ "//javatests/dagger/functional/kotlinsrc/multipackage/d",
+ "//javatests/dagger/functional/kotlinsrc/multipackage/foo",
+ ],
+ javacopts = DOCLINT_HTML_AND_SYNTAX + DOCLINT_REFERENCES,
+ deps = [
+ "//:dagger_with_compiler",
+ ],
+)
diff --git a/javatests/dagger/functional/kotlinsrc/multipackage/grandsub/FooGrandchildComponent.kt b/javatests/dagger/functional/kotlinsrc/multipackage/grandsub/FooGrandchildComponent.kt
new file mode 100644
index 0000000..bbc1b09
--- /dev/null
+++ b/javatests/dagger/functional/kotlinsrc/multipackage/grandsub/FooGrandchildComponent.kt
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2023 The Dagger Authors.
+ *
+ * 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 dagger.functional.kotlinsrc.multipackage.grandsub
+
+import dagger.Subcomponent
+import dagger.functional.kotlinsrc.multipackage.d.DModule
+import dagger.functional.kotlinsrc.multipackage.foo.Foo
+
+@Subcomponent(modules = [DModule::class])
+interface FooGrandchildComponent {
+ fun foo(): Foo<FooGrandchildComponent>
+}
diff --git a/javatests/dagger/functional/kotlinsrc/multipackage/moduleconstructor/BUILD b/javatests/dagger/functional/kotlinsrc/multipackage/moduleconstructor/BUILD
new file mode 100644
index 0000000..6039254
--- /dev/null
+++ b/javatests/dagger/functional/kotlinsrc/multipackage/moduleconstructor/BUILD
@@ -0,0 +1,34 @@
+# Copyright (C) 2023 The Dagger Authors.
+#
+# 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.
+
+# Description:
+# Functional tests for Dagger multipackage usages.
+
+load(
+ "//:build_defs.bzl",
+ "DOCLINT_HTML_AND_SYNTAX",
+ "DOCLINT_REFERENCES",
+)
+load("//:test_defs.bzl", "GenKtLibrary")
+
+package(default_visibility = ["//:src"])
+
+GenKtLibrary(
+ name = "moduleconstructor",
+ srcs = glob(["*.kt"]),
+ javacopts = DOCLINT_HTML_AND_SYNTAX + DOCLINT_REFERENCES,
+ deps = [
+ "//:dagger_with_compiler",
+ ],
+)
diff --git a/javatests/dagger/functional/kotlinsrc/multipackage/moduleconstructor/ModuleWithInaccessibleConstructor.kt b/javatests/dagger/functional/kotlinsrc/multipackage/moduleconstructor/ModuleWithInaccessibleConstructor.kt
new file mode 100644
index 0000000..45aa1ef
--- /dev/null
+++ b/javatests/dagger/functional/kotlinsrc/multipackage/moduleconstructor/ModuleWithInaccessibleConstructor.kt
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2023 The Dagger Authors.
+ *
+ * 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 dagger.functional.kotlinsrc.multipackage.moduleconstructor
+
+import dagger.Module
+import dagger.Provides
+import kotlin.random.Random
+
+@Module
+class ModuleWithInaccessibleConstructor
+/* intentionally package private */
+internal constructor() {
+ private val i: Int = Random.nextInt()
+
+ @Provides fun i(): Int = i
+}
diff --git a/javatests/dagger/functional/kotlinsrc/multipackage/primitives/BUILD b/javatests/dagger/functional/kotlinsrc/multipackage/primitives/BUILD
new file mode 100644
index 0000000..4060e3f
--- /dev/null
+++ b/javatests/dagger/functional/kotlinsrc/multipackage/primitives/BUILD
@@ -0,0 +1,34 @@
+# Copyright (C) 2023 The Dagger Authors.
+#
+# 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.
+
+# Description:
+# Functional tests for Dagger multipackage usages.
+
+load(
+ "//:build_defs.bzl",
+ "DOCLINT_HTML_AND_SYNTAX",
+ "DOCLINT_REFERENCES",
+)
+load("//:test_defs.bzl", "GenKtLibrary")
+
+package(default_visibility = ["//:src"])
+
+GenKtLibrary(
+ name = "primitives",
+ srcs = glob(["*.kt"]),
+ javacopts = DOCLINT_HTML_AND_SYNTAX + DOCLINT_REFERENCES,
+ deps = [
+ "//:dagger_with_compiler",
+ ],
+)
diff --git a/javatests/dagger/functional/kotlinsrc/multipackage/primitives/PrimitiveAcrossPackagesModule.kt b/javatests/dagger/functional/kotlinsrc/multipackage/primitives/PrimitiveAcrossPackagesModule.kt
new file mode 100644
index 0000000..15963af
--- /dev/null
+++ b/javatests/dagger/functional/kotlinsrc/multipackage/primitives/PrimitiveAcrossPackagesModule.kt
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2023 The Dagger Authors.
+ *
+ * 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 dagger.functional.kotlinsrc.multipackage.primitives
+
+import dagger.Module
+import dagger.Provides
+
+@Module
+object PrimitiveAcrossPackagesModule {
+ // This method should be internal so that a proxy method is created
+ @Provides internal fun primitive(): Boolean = false
+}
diff --git a/javatests/dagger/functional/kotlinsrc/multipackage/sub/BUILD b/javatests/dagger/functional/kotlinsrc/multipackage/sub/BUILD
new file mode 100644
index 0000000..86f3758
--- /dev/null
+++ b/javatests/dagger/functional/kotlinsrc/multipackage/sub/BUILD
@@ -0,0 +1,40 @@
+# Copyright (C) 2023 The Dagger Authors.
+#
+# 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.
+
+# Description:
+# Functional tests for Dagger multipackage usages.
+
+load(
+ "//:build_defs.bzl",
+ "DOCLINT_HTML_AND_SYNTAX",
+ "DOCLINT_REFERENCES",
+)
+load("//:test_defs.bzl", "GenKtLibrary")
+
+package(default_visibility = ["//:src"])
+
+GenKtLibrary(
+ name = "sub",
+ srcs = glob(["*.kt"]),
+ gen_library_deps = [
+ "//javatests/dagger/functional/kotlinsrc/multipackage/b",
+ "//javatests/dagger/functional/kotlinsrc/multipackage/c",
+ "//javatests/dagger/functional/kotlinsrc/multipackage/foo",
+ "//javatests/dagger/functional/kotlinsrc/multipackage/grandsub",
+ ],
+ javacopts = DOCLINT_HTML_AND_SYNTAX + DOCLINT_REFERENCES,
+ deps = [
+ "//:dagger_with_compiler",
+ ],
+)
diff --git a/javatests/dagger/functional/kotlinsrc/multipackage/sub/FooChildComponent.kt b/javatests/dagger/functional/kotlinsrc/multipackage/sub/FooChildComponent.kt
new file mode 100644
index 0000000..9364651
--- /dev/null
+++ b/javatests/dagger/functional/kotlinsrc/multipackage/sub/FooChildComponent.kt
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2023 The Dagger Authors.
+ *
+ * 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 dagger.functional.kotlinsrc.multipackage.sub
+
+import dagger.Subcomponent
+import dagger.functional.kotlinsrc.multipackage.b.BModule
+import dagger.functional.kotlinsrc.multipackage.c.CModule
+import dagger.functional.kotlinsrc.multipackage.foo.Foo
+import dagger.functional.kotlinsrc.multipackage.grandsub.FooGrandchildComponent
+
+@Subcomponent(modules = [BModule::class, CModule::class])
+interface FooChildComponent {
+ fun foo(): Foo<FooChildComponent>
+ fun fooGrandchildComponent(): FooGrandchildComponent
+}
diff --git a/javatests/dagger/functional/multipackage/BUILD b/javatests/dagger/functional/multipackage/BUILD
index 18b873e..a186e6e 100644
--- a/javatests/dagger/functional/multipackage/BUILD
+++ b/javatests/dagger/functional/multipackage/BUILD
@@ -24,8 +24,8 @@
package(default_visibility = ["//:src"])
-# TODO(b/265156633): These transitive dep shouldn't be needed, but are required because KSP
-# doesn't have access to transitive deps on classpath.
+# Looks like Dagger's strict deps exemption isn't working properly in Bazel
+# so we need to expose transitive deps?
TRANSITIVE_DEPS = [
"//javatests/dagger/functional/multipackage/b",
"//javatests/dagger/functional/multipackage/c",