add generated srcjar example for intellij validation
diff --git a/examples/dagger/BUILD b/examples/dagger/BUILD
index 38ea9bf..36685f7 100644
--- a/examples/dagger/BUILD
+++ b/examples/dagger/BUILD
@@ -36,10 +36,33 @@
exported_plugins = ["dagger_plugin"]
)
+# Generate a srcjar to validate intellij plugin correctly attaches it.
+genrule(
+ name = "tea_lib_src",
+ tools = ["@local_jdk//:jdk"],
+ cmd = """
+cat << EOF > TeaPot.kt
+package tea
+
+object TeaPot {
+ fun isEmpty() = true
+}
+EOF
+external/local_jdk/bin/jar -cf $@ TeaPot.kt
+""",
+ outs = ["donkey.srcjar"]
+)
+
+kt_jvm_library(
+ name = "tea_lib",
+ srcs = [":tea_lib_src"]
+)
+
kt_jvm_library(
name = "coffee_lib",
srcs = glob(["src/**"]),
deps = [
+ ":tea_lib",
":dagger_lib",
"//third_party:kotlinx_coroutines"
],
diff --git a/examples/dagger/src/coffee/CoffeeApp.kt b/examples/dagger/src/coffee/CoffeeApp.kt
index 5af91b6..ab08a5c 100644
--- a/examples/dagger/src/coffee/CoffeeApp.kt
+++ b/examples/dagger/src/coffee/CoffeeApp.kt
@@ -18,6 +18,7 @@
import dagger.Component
import kotlinx.coroutines.experimental.runBlocking
import javax.inject.Singleton
+import tea.TeaPot
class CoffeeApp {
@Singleton
@@ -29,9 +30,11 @@
companion object {
@JvmStatic
fun main(args: Array<String>) {
- val coffeeShop = DaggerCoffeeApp_CoffeeShop.builder().build()
- runBlocking {
- coffeeShop.maker().brew()
+ if(TeaPot.isEmpty()) {
+ val coffeeShop = DaggerCoffeeApp_CoffeeShop.builder().build()
+ runBlocking {
+ coffeeShop.maker().brew()
+ }
}
}
}