bazelbuild / intellij

IntelliJ plugin for Bazel projects
https://ij.bazel.build/
Apache License 2.0
764 stars 305 forks source link

Unable to add kotlin_library to android_binary w/ kotlin v2 #220

Closed holmes closed 6 years ago

holmes commented 6 years ago

Referenced from https://github.com/bazelbuild/intellij/pull/217

I've got almost all my packages building, but it's failing when I try to put a kotlin_library in an android_binary with the error:

/work/catalog holmes/new-kotlin-rules * ./bazelw mobile-install --start_app //src/test/java/com/squareup/thyme:thyme
ERROR: /work/catalog/src/test/java/com/squareup/thyme/BUILD:53:15: in exports attribute of android_library rule //src/test/java/com/squareup/thyme:java: kotlin_library rule '//src/test/java/com/squareup/thyme:kt' is misplaced here (expected aar_import, android_library, cc_library, java_import, java_library or java_lite_proto_library)
ERROR: Analysis of target '//src/test/java/com/squareup/thyme:thyme' failed; build aborted: Analysis of target '//src/test/java/com/squareup/thyme:java' failed; build aborted
INFO: Elapsed time: 4.541s

Kotlin definition:

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

kotlin_library(
    name = "kt",
    srcs = glob(["MainActivityPresenter.kt"]),
    deps = [
        ":res",
        "@com_android_support_appcompat_v7_27_0_2//aar",
        "@com_android_support_animated_vector_drawable_27_0_2//aar",
        "@com_android_support_support_annotations_27_0_2//jar",
        "@com_android_support_support_vector_drawable_27_0_2//aar",
        "@com_android_support_support_core_utils_27_0_2//aar",
        "@com_android_support_support_core_ui_27_0_2//aar",
        "@com_android_support_support_fragment_27_0_2//aar",
        "@com_android_support_support_compat_27_0_2//aar",
        "@com_android_support_recyclerview_v7_27_0_2//aar",
        "//src/test/java/com/squareup/thyme/utilities:utilities",
        "//src/test/java/com/squareup/thyme/calendar:calendar",
        "@android_arch_lifecycle_common_1_0_3//jar",
        "//third_party:rxbinding",
        "//third_party:rxjava",
        "//src/main/java/com/squareup/shared/serum/event",
        "//src/main/java/com/squareup/shared/serum/store",
    ],
)

Android binary definition:

android_binary(
    name = "thyme",
    srcs = glob(["*.java"]),
    custom_package = PACKAGE,
    manifest = MANIFEST,
    manifest_values = {
        "minSdkVersion": "21",
        "targetSdkVersion": "27",
    },
    multidex = "native",
    deps = [
        ":java",
        ":kt",
        ":res",
        "//src/main/java/com/squareup/shared/appointments/calendar/layout",
        "//src/main/java/com/squareup/shared/appointments/calendar/model",
        "//src/main/java/com/squareup/shared/appointments/calendar/stores",
        "//src/main/java/com/squareup/shared/appointments/sync/model",
        "//src/main/java/com/squareup/shared/serum/event",
        "//src/main/java/com/squareup/shared/serum/store",
        "//third_party:dagger",
        "//third_party:rxandroid",
        "//third_party:rxbinding",
        "//third_party:rxjava",
        "@android_arch_core_runtime_1_0_0//aar",
        "@android_arch_lifecycle_common_1_0_3//jar",
        "@android_arch_lifecycle_runtime_1_0_3//aar",
        "@com_android_support_animated_vector_drawable_27_0_2//aar",
        "@com_android_support_appcompat_v7_27_0_2//aar",
        "@com_android_support_recyclerview_v7_27_0_2//aar",
        "@com_android_support_support_annotations_27_0_2//jar",
        "@com_android_support_support_compat_27_0_2//aar",
        "@com_android_support_support_core_ui_27_0_2//aar",
        "@com_android_support_support_core_utils_27_0_2//aar",
        "@com_android_support_support_fragment_27_0_2//aar",
        "@com_android_support_support_vector_drawable_27_0_2//aar",
    ],
)
brendandouglas commented 6 years ago

Unless I'm misunderstanding, this is an issue with the underlying bazel rules, not the plugin. Could you move this issue to the kotlin rules repo or the bazel repo?

holmes commented 6 years ago

Moved to https://github.com/hsyed/rules_kotlin/issues/8