add kotlinx coroutines to coffee app for ij verification
diff --git a/examples/dagger/BUILD b/examples/dagger/BUILD
index 50a0ef0..38ea9bf 100644
--- a/examples/dagger/BUILD
+++ b/examples/dagger/BUILD
@@ -39,7 +39,10 @@
kt_jvm_library(
name = "coffee_lib",
srcs = glob(["src/**"]),
- deps = [":dagger_lib"],
+ deps = [
+ ":dagger_lib",
+ "//third_party:kotlinx_coroutines"
+ ],
)
java_binary(
diff --git a/examples/dagger/src/coffee/CoffeeApp.kt b/examples/dagger/src/coffee/CoffeeApp.kt
index ad5ae65..5af91b6 100644
--- a/examples/dagger/src/coffee/CoffeeApp.kt
+++ b/examples/dagger/src/coffee/CoffeeApp.kt
@@ -16,6 +16,7 @@
package coffee
import dagger.Component
+import kotlinx.coroutines.experimental.runBlocking
import javax.inject.Singleton
class CoffeeApp {
@@ -29,7 +30,9 @@
@JvmStatic
fun main(args: Array<String>) {
val coffeeShop = DaggerCoffeeApp_CoffeeShop.builder().build()
- coffeeShop.maker().brew()
+ runBlocking {
+ coffeeShop.maker().brew()
+ }
}
}
}
diff --git a/examples/dagger/src/coffee/CoffeeMaker.kt b/examples/dagger/src/coffee/CoffeeMaker.kt
index beb1bd8..6ef95a4 100644
--- a/examples/dagger/src/coffee/CoffeeMaker.kt
+++ b/examples/dagger/src/coffee/CoffeeMaker.kt
@@ -16,19 +16,23 @@
package coffee
import dagger.Lazy
-
+import kotlinx.coroutines.experimental.DefaultDispatcher
+import kotlinx.coroutines.experimental.withContext
import javax.inject.Inject
class CoffeeMaker @Inject internal constructor(
- // Create a possibly costly heater only when we use it.
- private val heater: Lazy<Heater>,
- private val pump: Pump
+ // Create a possibly costly heater only when we use it.
+ private val heater: Lazy<Heater>,
+ private val pump: Pump
) {
- fun brew() {
- heater.get().on()
- pump.pump()
- println(" [_]P coffee! [_]P ")
- heater.get().off()
+ suspend fun brew() {
+ // this function is async to verify intellij support for coroutines.
+ withContext(DefaultDispatcher) {
+ heater.get().on()
+ pump.pump()
+ println(" [_]P coffee! [_]P ")
+ heater.get().off()
+ }
}
}
diff --git a/third_party/BUILD b/third_party/BUILD
index 2150165..0746542 100644
--- a/third_party/BUILD
+++ b/third_party/BUILD
@@ -12,9 +12,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.
package(default_visibility = ["//visibility:public"])
+load("//kotlin:kotlin.bzl", "kt_jvm_import")
java_binary(
name = "bazel_deps",
main_class = "com.github.johnynek.bazel_deps.ParseProject",
runtime_deps = ["@bazel_deps//jar"],
+)
+
+kt_jvm_import(
+ name = "kotlinx_coroutines",
+ jars = [
+ "@io_bazel_rules_kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core//jar",
+ ],
)
\ No newline at end of file
diff --git a/third_party/dependencies.yaml b/third_party/dependencies.yaml
index ca64699..8132b15 100644
--- a/third_party/dependencies.yaml
+++ b/third_party/dependencies.yaml
@@ -5,6 +5,7 @@
- id: "mavencentral"
type: "default"
url: https://repo.maven.apache.org/maven2/
+ resolverType: coursier
transitivity: runtime_deps
versionConflictPolicy: highest
namePrefix: "io_bazel_rules_kotlin_"
@@ -44,6 +45,11 @@
modules: ["", "compiler", "producers"]
lang: "java"
version: "2.9"
+ org.jetbrains.kotlinx:
+ kotlinx-coroutines:
+ modules: ["core"]
+ lang: "java"
+ version : "0.23.1"
replacements:
org.jetbrains.kotlin:
diff --git a/third_party/jvm/org/jetbrains/kotlin/BUILD b/third_party/jvm/org/jetbrains/kotlin/BUILD
index ec836d2..8bf2e22 100644
--- a/third_party/jvm/org/jetbrains/kotlin/BUILD
+++ b/third_party/jvm/org/jetbrains/kotlin/BUILD
@@ -34,3 +34,15 @@
)
+
+java_library(
+ name = "kotlin_stdlib_common",
+ exports = [
+ "//external:jar/io_bazel_rules_kotlin_org/jetbrains/kotlin/kotlin_stdlib_common"
+ ],
+ visibility = [
+ "//visibility:public"
+ ]
+)
+
+
diff --git a/third_party/jvm/org/jetbrains/kotlinx/BUILD b/third_party/jvm/org/jetbrains/kotlinx/BUILD
new file mode 100644
index 0000000..8f4846c
--- /dev/null
+++ b/third_party/jvm/org/jetbrains/kotlinx/BUILD
@@ -0,0 +1,44 @@
+licenses(["notice"])
+java_library(
+ name = "atomicfu_common",
+ exports = [
+ "//external:jar/io_bazel_rules_kotlin_org/jetbrains/kotlinx/atomicfu_common"
+ ],
+ visibility = [
+ "//visibility:public"
+ ]
+)
+
+
+
+java_library(
+ name = "kotlinx_coroutines_core",
+ exports = [
+ "//external:jar/io_bazel_rules_kotlin_org/jetbrains/kotlinx/kotlinx_coroutines_core"
+ ],
+ runtime_deps = [
+ "//third_party/jvm/org/jetbrains/kotlin:kotlin_stdlib",
+ ":kotlinx_coroutines_core_common"
+ ],
+ visibility = [
+ "//visibility:public"
+ ]
+)
+
+
+
+java_library(
+ name = "kotlinx_coroutines_core_common",
+ exports = [
+ "//external:jar/io_bazel_rules_kotlin_org/jetbrains/kotlinx/kotlinx_coroutines_core_common"
+ ],
+ runtime_deps = [
+ "//third_party/jvm/org/jetbrains/kotlin:kotlin_stdlib_common",
+ ":atomicfu_common"
+ ],
+ visibility = [
+ "//visibility:public"
+ ]
+)
+
+
diff --git a/third_party/jvm/workspace.bzl b/third_party/jvm/workspace.bzl
index bf5d21a..fdcc1b6 100644
--- a/third_party/jvm/workspace.bzl
+++ b/third_party/jvm/workspace.bzl
@@ -43,6 +43,10 @@
{"artifact": "org.checkerframework:checker-compat-qual:2.0.0", "lang": "java", "sha1": "fc89b03860d11d6213d0154a62bcd1c2f69b9efa", "repository": "https://repo.maven.apache.org/maven2/", "name": "io_bazel_rules_kotlin_org_checkerframework_checker_compat_qual", "actual": "@io_bazel_rules_kotlin_org_checkerframework_checker_compat_qual//jar", "bind": "jar/io_bazel_rules_kotlin_org/checkerframework/checker_compat_qual"},
{"artifact": "org.codehaus.mojo:animal-sniffer-annotations:1.14", "lang": "java", "sha1": "775b7e22fb10026eed3f86e8dc556dfafe35f2d5", "repository": "https://repo.maven.apache.org/maven2/", "name": "io_bazel_rules_kotlin_org_codehaus_mojo_animal_sniffer_annotations", "actual": "@io_bazel_rules_kotlin_org_codehaus_mojo_animal_sniffer_annotations//jar", "bind": "jar/io_bazel_rules_kotlin_org/codehaus/mojo/animal_sniffer_annotations"},
{"artifact": "org.hamcrest:hamcrest-core:1.3", "lang": "java", "sha1": "42a25dc3219429f0e5d060061f71acb49bf010a0", "repository": "https://repo.maven.apache.org/maven2/", "name": "io_bazel_rules_kotlin_org_hamcrest_hamcrest_core", "actual": "@io_bazel_rules_kotlin_org_hamcrest_hamcrest_core//jar", "bind": "jar/io_bazel_rules_kotlin_org/hamcrest/hamcrest_core"},
+ {"artifact": "org.jetbrains.kotlin:kotlin-stdlib-common:1.2.41", "lang": "java", "sha1": "bf0bdac1048fd1c5c54362978dd7e06bd2230e78", "repository": "https://repo.maven.apache.org/maven2/", "name": "io_bazel_rules_kotlin_org_jetbrains_kotlin_kotlin_stdlib_common", "actual": "@io_bazel_rules_kotlin_org_jetbrains_kotlin_kotlin_stdlib_common//jar", "bind": "jar/io_bazel_rules_kotlin_org/jetbrains/kotlin/kotlin_stdlib_common"},
+ {"artifact": "org.jetbrains.kotlinx:atomicfu-common:0.10.1", "lang": "java", "sha1": "4eb87291dff597f2f5bac4876fae02ef23466a39", "repository": "https://repo.maven.apache.org/maven2/", "name": "io_bazel_rules_kotlin_org_jetbrains_kotlinx_atomicfu_common", "actual": "@io_bazel_rules_kotlin_org_jetbrains_kotlinx_atomicfu_common//jar", "bind": "jar/io_bazel_rules_kotlin_org/jetbrains/kotlinx/atomicfu_common"},
+ {"artifact": "org.jetbrains.kotlinx:kotlinx-coroutines-core-common:0.23.1", "lang": "java", "sha1": "ee988a3e0a918579315ce6654f415b47fec39d36", "repository": "https://repo.maven.apache.org/maven2/", "name": "io_bazel_rules_kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core_common", "actual": "@io_bazel_rules_kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core_common//jar", "bind": "jar/io_bazel_rules_kotlin_org/jetbrains/kotlinx/kotlinx_coroutines_core_common"},
+ {"artifact": "org.jetbrains.kotlinx:kotlinx-coroutines-core:0.23.1", "lang": "java", "sha1": "fb67b623766f0b2d56697f0b8ed14450f285b8ed", "repository": "https://repo.maven.apache.org/maven2/", "name": "io_bazel_rules_kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core", "actual": "@io_bazel_rules_kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core//jar", "bind": "jar/io_bazel_rules_kotlin_org/jetbrains/kotlinx/kotlinx_coroutines_core"},
]
def maven_dependencies(callback = declare_maven):