Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion examples/android/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ load("@rules_jvm_external//:defs.bzl", "maven_install")
maven_install(
artifacts = [
"androidx.appcompat:appcompat:1.0.0",
"com.nhaarman:mockito-kotlin:1.5.0",
"junit:junit:4.12",
"androidx.test.espresso:espresso-core:3.1.1",
"org.hamcrest:hamcrest-library:1.3",
Expand All @@ -37,6 +38,7 @@ maven_install(
"com.google.dagger:dagger-producers:2.35.1",
"com.google.auto.value:auto-value:1.6.5",
"com.google.auto.value:auto-value-annotations:1.6.5",
"org.robolectric:robolectric:4.4",
],
repositories = [
"https://maven.google.com",
Expand Down Expand Up @@ -80,7 +82,18 @@ kt_download_local_dev_dependencies()

load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kotlin_repositories")

kotlin_repositories()
KOTLIN_VERSION = "1.5.10"
KOTLINC_RELEASE_SHA = "2f8de1d73b816354055ff6a4b974b711c11ad55a68b948ed30b38155706b3c4e"

KOTLINC_RELEASE = {
"urls": [
"https://github.com/JetBrains/kotlin/releases/download/v{v}/kotlin-compiler-{v}.zip".format(v = KOTLIN_VERSION),
],
"sha256": KOTLINC_RELEASE_SHA,
}

kotlin_repositories(compiler_release = KOTLINC_RELEASE)


register_toolchains("//bzl:experimental_toolchain")

Expand All @@ -89,3 +102,12 @@ http_archive(
sha256 = "4ba8f4ab0ff85f2484287ab06c0d871dcb31cc54d439457d28fd4ae14b18450a",
url = "https://github.com/bazelbuild/rules_pkg/releases/download/0.2.4/rules_pkg-0.2.4.tar.gz",
)

http_archive(
name = "robolectric",
urls = ["https://github.com/robolectric/robolectric-bazel/archive/4.4.tar.gz"],
strip_prefix = "robolectric-bazel-4.4",
)
load("@robolectric//bazel:robolectric.bzl", "robolectric_repositories")
robolectric_repositories()

4 changes: 2 additions & 2 deletions examples/android/bzl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ kt_javac_options(

define_kt_toolchain(
name = "experimental_toolchain",
api_version = "1.4",
api_version = "1.5",
experimental_reduce_classpath_mode = "KOTLINBUILDER_REDUCED",
experimental_report_unused_deps = "warn",
experimental_strict_kotlin_deps = "warn",
experimental_use_abi_jars = True,
javac_options = ":default_javac_options",
kotlinc_options = ":default_kotlinc_options",
language_version = "1.4",
language_version = "1.5",
)
33 changes: 31 additions & 2 deletions examples/android/libAndroid/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_jvm_library")
load("@build_bazel_rules_android//android:rules.bzl", "android_library")
load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_jvm_library", "kt_android_library")
load("@build_bazel_rules_android//android:rules.bzl", "android_library", "android_local_test")

android_library(
name = "my_android",
Expand All @@ -18,3 +18,32 @@ kt_jvm_library(
name = "util",
srcs = glob(["src/main/kotlin/**/*.kt"]),
)

kt_android_library(
name = "test_src",
srcs = glob(["src/test/kotlin/**/*.kt"]),
custom_package = "examples.android.lib2",
manifest = "src/main/AndroidManifest.xml",
visibility = ["//visibility:public"],
deps = [
":util",
"@maven//:junit_junit",
"@maven//:com_nhaarman_mockito_kotlin",
],
)

android_local_test(
name = "Test",
test_class = "examples.android.lib2.TestDataTest",
manifest_values = {
"minSdkVersion": "23",
"applicationId": "com.snap.mushroom.test",
},
custom_package = "examples.android.lib2",
deps = [
":test_src",
"@robolectric//bazel:android-all",
"@maven//:junit_junit",
"@maven//:com_nhaarman_mockito_kotlin",
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package examples.android.lib2

private typealias TestAlias = Int

interface TestData {
val a: TestAlias
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package examples.android.lib2

import com.nhaarman.mockito_kotlin.mock
import org.junit.Test

class TestDataTest {
@Test
fun test1() {
val a = object : TestData {
override val a: Int = 1
}
}
}
9 changes: 9 additions & 0 deletions examples/associates/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "define_kt_toolchain")

define_kt_toolchain(
name = "kotlin_toolchain",
api_version = "1.5", # "1.1", "1.2", "1.3", or "1.4"
jvm_target = "1.8", # "1.6", "1.8", "9", "10", "11", "12", or "13",
language_version = "1.5", # "1.1", "1.2", "1.3", or "1.4"
)
23 changes: 21 additions & 2 deletions examples/associates/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ http_archive(
urls = ["https://github.com/bazelbuild/rules_android/archive/v0.1.1.zip"],
)

android_sdk_repository(
name = "androidsdk",
api_level = 30, # The version of the Android API that the SDK target
build_tools_version = "30.0.2",
)


http_archive(
name = "bazel_skylib",
sha256 = SKYLIB_SHA,
Expand All @@ -29,15 +36,26 @@ local_repository(
path = "../..",
)


load("@io_bazel_rules_kotlin//kotlin:dependencies.bzl", "kt_download_local_dev_dependencies")

kt_download_local_dev_dependencies()

load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kotlin_repositories", "kt_register_toolchains")

kotlin_repositories()
KOTLIN_VERSION = "1.5.10"
KOTLINC_RELEASE_SHA = "2f8de1d73b816354055ff6a4b974b711c11ad55a68b948ed30b38155706b3c4e"

KOTLINC_RELEASE = {
"urls": [
"https://github.com/JetBrains/kotlin/releases/download/v{v}/kotlin-compiler-{v}.zip".format(v = KOTLIN_VERSION),
],
"sha256": KOTLINC_RELEASE_SHA,
}

kotlin_repositories(compiler_release = KOTLINC_RELEASE)

kt_register_toolchains()
register_toolchains("//:kotlin_toolchain")

RULES_JVM_EXTERNAL_TAG = "2.7"

Expand All @@ -55,6 +73,7 @@ load("@rules_jvm_external//:defs.bzl", "maven_install")
maven_install(
artifacts = [
"junit:junit:4.13",
"com.nhaarman:mockito-kotlin:1.5.0",
],
repositories = [
"https://repo1.maven.org/maven2",
Expand Down
17 changes: 15 additions & 2 deletions examples/associates/projects/core/impl/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_jvm_library")
load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_jvm_library", "kt_jvm_test")

kt_jvm_library(
name = "impl",
srcs = glob(["src/main/kotlin/**/*.kt"]),
srcs = glob(["src/main/java/**/*.kt"]),
associates = ["//projects/core/api"],
visibility = [
"//projects/core:__subpackages__",
Expand All @@ -11,3 +11,16 @@ kt_jvm_library(
# All my deps are associates.
],
)

kt_jvm_test(
name = "Test",
srcs = glob(["src/test/java/**/*.kt"]),
associates = [
"//projects/core/api",
"//projects/core/impl",
],
deps = [
"@maven//:junit_junit",
"@maven//:com_nhaarman_mockito_kotlin",
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package core.impl

private typealias TestAlias = Int

interface TestData {
val a: TestAlias
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package core.impl

import com.nhaarman.mockito_kotlin.mock
import org.junit.Test

class TestDataTest {
@Test
fun test1() {
val a = object : TestData {
override val a: Int = 1
}
}
}

This file was deleted.

2 changes: 2 additions & 0 deletions kotlin/internal/toolchains.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ _kt_toolchain = rule(
"1.2",
"1.3",
"1.4",
"1.5",
],
),
"api_version": attr.string(
Expand All @@ -139,6 +140,7 @@ _kt_toolchain = rule(
"1.2",
"1.3",
"1.4",
"1.5",
],
),
"debug": attr.string_list(
Expand Down