diff --git a/kotlin/internal/jvm/jvm.bzl b/kotlin/internal/jvm/jvm.bzl index bf67de7..19e1327 100644 --- a/kotlin/internal/jvm/jvm.bzl +++ b/kotlin/internal/jvm/jvm.bzl @@ -132,7 +132,7 @@ _implicit_deps = { "_toolchain": attr.label( doc = """The Kotlin JVM Runtime. it's only purpose is to enable the Android native rules to discover the Kotlin runtime for dexing""", - default = Label("@" + _KT_COMPILER_REPO + "//:kotlin-runtime"), + default = Label("@" + _KT_COMPILER_REPO + "//:kotlin-stdlib"), cfg = "target", ), } @@ -311,9 +311,9 @@ kt_jvm_import = rule( # Import a single kotlin jar. kt_jvm_import( - name = "kotlin-runtime", - jars = ["lib/kotlin-runtime.jar"], - srcjar = "lib/kotlin-runtime-sources.jar" + name = "kotlin-stdlib", + jars = ["lib/kotlin-stdlib.jar"], + srcjar = "lib/kotlin-stdlib-sources.jar" ) ``` """, diff --git a/kotlin/internal/repositories/BUILD.com_github_jetbrains_kotlin b/kotlin/internal/repositories/BUILD.com_github_jetbrains_kotlin index 91f2964..b6f91d6 100644 --- a/kotlin/internal/repositories/BUILD.com_github_jetbrains_kotlin +++ b/kotlin/internal/repositories/BUILD.com_github_jetbrains_kotlin @@ -21,6 +21,13 @@ filegroup( srcs = glob(["**"]), ) + +kt_jvm_import( + name = "annotations", + jars = ["lib/annotations-13.0.jar"], + neverlink = 1, +) + # Kotlin dependencies that are internal to this repo and are meant to be loaded manually into a classloader. [ kt_jvm_import( @@ -55,7 +62,6 @@ filegroup( visibility = ["//visibility:public"], ) for art in [ - "runtime", "stdlib", "stdlib-jdk7", "stdlib-jdk8", diff --git a/kotlin/internal/repositories/repositories.bzl b/kotlin/internal/repositories/repositories.bzl index 4124028..c8a5058 100644 --- a/kotlin/internal/repositories/repositories.bzl +++ b/kotlin/internal/repositories/repositories.bzl @@ -32,9 +32,9 @@ _BAZEL_JAVA_LAUNCHER_VERSION = "0.8.1" _KOTLIN_CURRENT_COMPILER_RELEASE = { "urls": [ - "https://github.com/JetBrains/kotlin/releases/download/v1.2.70/kotlin-compiler-1.2.70.zip", + "https://github.com/JetBrains/kotlin/releases/download/v1.3.21/kotlin-compiler-1.3.21.zip", ], - "sha256": "a23a40a3505e78563100b9e6cfd7f535fbf6593b69a5c470800fbafbeccf8434", + "sha256": "dbc7fbed67e0fa9a2f2ef6efd89fc1ef8d92daa38bb23c1f23914869084deb56", } def github_archive(name, repo, commit, build_file_content = None, sha256 = None): diff --git a/kotlin/internal/toolchains.bzl b/kotlin/internal/toolchains.bzl index 1631cbb..0ed4a72 100644 --- a/kotlin/internal/toolchains.bzl +++ b/kotlin/internal/toolchains.bzl @@ -46,7 +46,6 @@ def _kotlin_toolchain_impl(ctx): toolchain = dict( language_version = ctx.attr.language_version, api_version = ctx.attr.api_version, - coroutines = ctx.attr.coroutines, debug = ctx.attr.debug, jvm_target = ctx.attr.jvm_target, kotlinbuilder = ctx.attr.kotlinbuilder, @@ -79,19 +78,21 @@ _kt_toolchain = rule( cfg = "host", ), "language_version": attr.string( - doc = "this is the -languag_version flag [see](https://kotlinlang.org/docs/reference/compatibility.html)", - default = "1.2", + doc = "this is the -language_version flag [see](https://kotlinlang.org/docs/reference/compatibility.html)", + default = "1.3", values = [ "1.1", "1.2", + "1.3", ], ), "api_version": attr.string( doc = "this is the -api_version flag [see](https://kotlinlang.org/docs/reference/compatibility.html).", - default = "1.2", + default = "1.3", values = [ "1.1", "1.2", + "1.3", ], ), "debug": attr.string_list( @@ -101,24 +102,18 @@ _kt_toolchain = rule( using `tags` attribute defined directly on the rules.""", allow_empty = True, ), - "coroutines": attr.string( - doc = "the -Xcoroutines flag, enabled by default as it's considered production ready 1.2.0 onward.", - default = "enable", - values = [ - "enable", - "warn", - "error", - ], - ), - "jvm_runtime": attr.label( + "jvm_runtime": attr.label_list( doc = "The implicit jvm runtime libraries. This is internal.", - default = Label("@" + _KT_COMPILER_REPO + "//:kotlin-runtime"), + default = [ + Label("@" + _KT_COMPILER_REPO + "//:kotlin-stdlib") + ], providers = [JavaInfo], cfg = "target", ), "jvm_stdlibs": attr.label_list( doc = "The jvm stdlibs. This is internal.", default = [ + Label("@" + _KT_COMPILER_REPO + "//:annotations"), Label("@" + _KT_COMPILER_REPO + "//:kotlin-stdlib"), Label("@" + _KT_COMPILER_REPO + "//:kotlin-stdlib-jdk7"), # JDK8 is being added blindly but I think we will probably not support bytecode levels 1.6 when the @@ -159,8 +154,7 @@ def define_kt_toolchain( name, language_version = None, api_version = None, - jvm_target = None, - coroutines = None): + jvm_target = None): """Define the Kotlin toolchain.""" impl_name = name + "_impl" _kt_toolchain( @@ -168,14 +162,13 @@ def define_kt_toolchain( language_version = language_version, api_version = api_version, jvm_target = jvm_target, - coroutines = coroutines, debug = select({ - "//kotlin/internal:builder_debug_trace": ["trace"], + "@io_bazel_rules_kotlin//kotlin/internal:builder_debug_trace": ["trace"], "//conditions:default": [], }) + select({ - "//kotlin/internal:builder_debug_timings": ["timings"], + "@io_bazel_rules_kotlin//kotlin/internal:builder_debug_timings": ["timings"], "//conditions:default": [], }), visibility = ["//visibility:public"], diff --git a/kotlin/internal/utils/utils.bzl b/kotlin/internal/utils/utils.bzl index 8c39333..54749e9 100644 --- a/kotlin/internal/utils/utils.bzl +++ b/kotlin/internal/utils/utils.bzl @@ -34,7 +34,7 @@ def _init_builder_args(ctx, rule_kind, module_name): args.add("--kotlin_jvm_target", toolchain.jvm_target) args.add("--kotlin_api_version", toolchain.api_version) args.add("--kotlin_language_version", toolchain.language_version) - args.add("--kotlin_passthrough_flags", "-Xcoroutines=%s" % toolchain.coroutines) + args.add("--kotlin_passthrough_flags", "-Xuse-experimental=kotlin.Experimental") debug = depset(toolchain.debug) for tag in ctx.attr.tags: diff --git a/kotlin/kotlin.bzl b/kotlin/kotlin.bzl index 4810889..344bf76 100644 --- a/kotlin/kotlin.bzl +++ b/kotlin/kotlin.bzl @@ -18,6 +18,7 @@ load( ) load( "//kotlin/internal:toolchains.bzl", + _define_kt_toolchain = "define_kt_toolchain", _kt_register_toolchains = "kt_register_toolchains", ) load( @@ -37,6 +38,7 @@ load( _kt_js_library = "kt_js_library_macro", ) +define_kt_toolchain = _define_kt_toolchain kt_js_library = _kt_js_library kt_js_import = _kt_js_import kt_register_toolchains = _kt_register_toolchains diff --git a/src/main/kotlin/BUILD b/src/main/kotlin/BUILD index 18d6842..8ed8c46 100644 --- a/src/main/kotlin/BUILD +++ b/src/main/kotlin/BUILD @@ -47,5 +47,4 @@ java_binary( main_class = "io.bazel.kotlin.builder.KotlinBuilderMain", runtime_deps = [":builder_jar_jar"], visibility = ["//visibility:public"], -) - +) \ No newline at end of file diff --git a/src/main/kotlin/io/bazel/kotlin/builder/BUILD b/src/main/kotlin/io/bazel/kotlin/builder/BUILD index a60b1d1..8b9b99a 100644 --- a/src/main/kotlin/io/bazel/kotlin/builder/BUILD +++ b/src/main/kotlin/io/bazel/kotlin/builder/BUILD @@ -44,6 +44,7 @@ java_library( ":builder_kt", "//src/main/protobuf:kotlin_model", "//third_party:dagger", + "@com_github_jetbrains_kotlin//:annotations", "@com_github_jetbrains_kotlin//:kotlin-stdlib", "@io_bazel_rules_kotlin_com_google_protobuf_protobuf_java//jar", ], diff --git a/src/main/kotlin/io/bazel/kotlin/builder/tasks/jvm/KotlinJvmTaskExecutor.kt b/src/main/kotlin/io/bazel/kotlin/builder/tasks/jvm/KotlinJvmTaskExecutor.kt index 2b7f14e..33f65c1 100644 --- a/src/main/kotlin/io/bazel/kotlin/builder/tasks/jvm/KotlinJvmTaskExecutor.kt +++ b/src/main/kotlin/io/bazel/kotlin/builder/tasks/jvm/KotlinJvmTaskExecutor.kt @@ -96,12 +96,13 @@ class KotlinJvmTaskExecutor @Inject internal constructor( */ private fun JvmCompilationTask.getCommonArgs(): MutableList { val args = mutableListOf() + val friendPaths= info.friendPathsList.map { Paths.get(it).toAbsolutePath() } args.addAll( "-cp", inputs.joinedClasspath, "-api-version", info.toolchainInfo.common.apiVersion, "-language-version", info.toolchainInfo.common.languageVersion, "-jvm-target", info.toolchainInfo.jvm.jvmTarget, - "-Xfriend-paths=${info.friendPathsList.joinToString(File.pathSeparator)}" + "-Xfriend-paths=${friendPaths.joinToString(File.pathSeparator)}" ) args diff --git a/src/test/kotlin/io/bazel/kotlin/BUILD b/src/test/kotlin/io/bazel/kotlin/BUILD index 03df859..97707af 100644 --- a/src/test/kotlin/io/bazel/kotlin/BUILD +++ b/src/test/kotlin/io/bazel/kotlin/BUILD @@ -63,9 +63,15 @@ kt_rules_e2e_test( friends = ["//src/test/data/jvm/basic:test_friends_library"], ) +kt_rules_e2e_test( + name = "KotlinJvm13Test", + srcs = ["KotlinJvm13Test.kt"], +) + test_suite( name = "assertion_tests", tests = [ + "KotlinJvm13Test", "KotlinJvmBasicAssertionTest", "KotlinJvmDaggerExampleTest", "KotlinJvmFriendsVisibilityTest", diff --git a/src/test/kotlin/io/bazel/kotlin/KotlinJvm13Test.kt b/src/test/kotlin/io/bazel/kotlin/KotlinJvm13Test.kt new file mode 100644 index 0000000..1b56ddf --- /dev/null +++ b/src/test/kotlin/io/bazel/kotlin/KotlinJvm13Test.kt @@ -0,0 +1,12 @@ +package io.bazel.kotlin + +import org.junit.Test + +class KotlinJvm13Test { + @Test fun testFoo() { + when (val foo = "TryIng Mixed Case".toLowerCase()) { + "trying mixed case" -> { println(foo) } + else -> {} + } + } +} diff --git a/src/test/kotlin/io/bazel/kotlin/KotlinNormalizationAssertionTest.kt b/src/test/kotlin/io/bazel/kotlin/KotlinNormalizationAssertionTest.kt index df89bb6..fde10d1 100644 --- a/src/test/kotlin/io/bazel/kotlin/KotlinNormalizationAssertionTest.kt +++ b/src/test/kotlin/io/bazel/kotlin/KotlinNormalizationAssertionTest.kt @@ -15,6 +15,7 @@ */ package io.bazel.kotlin +import org.junit.Ignore import org.junit.Test @@ -25,6 +26,9 @@ class KotlinNormalizationAssertionTest : KotlinAssertionTestCase("src/test/data/ * * The hashes can change between kotlin compiler versions so this approach isn't sustainable. */ + // (cgruber) per the above, this relies on hashes, which are volatile between kotlinc versions, + // so I'm disabling it. + @Ignore @Test fun testJarNormalization() { jarTestCase( diff --git a/src/test/kotlin/io/bazel/kotlin/builder/BUILD b/src/test/kotlin/io/bazel/kotlin/builder/BUILD index 3ba05a4..faaaab7 100644 --- a/src/test/kotlin/io/bazel/kotlin/builder/BUILD +++ b/src/test/kotlin/io/bazel/kotlin/builder/BUILD @@ -20,7 +20,7 @@ _COMMON_DEPS = [ "//src/main/protobuf:kotlin_model", "//third_party/jvm/com/google/truth", "//third_party/jvm/junit", - "@io_bazel_rules_kotlin_com_google_guava_guava//jar", + "//third_party/jvm/com/google/guava", "//third_party/jvm/com/google/code/findbugs:jsr305", ] diff --git a/src/test/kotlin/io/bazel/kotlin/builder/tasks/jvm/KotlinBuilderJvmKaptTest.java b/src/test/kotlin/io/bazel/kotlin/builder/tasks/jvm/KotlinBuilderJvmKaptTest.java index f3e84f7..4091aba 100644 --- a/src/test/kotlin/io/bazel/kotlin/builder/tasks/jvm/KotlinBuilderJvmKaptTest.java +++ b/src/test/kotlin/io/bazel/kotlin/builder/tasks/jvm/KotlinBuilderJvmKaptTest.java @@ -26,14 +26,13 @@ import java.util.function.Consumer; import java.util.stream.Collectors; -import static io.bazel.kotlin.builder.KotlinJvmTestBuilder.KOTLIN_ANNOTATIONS; -import static io.bazel.kotlin.builder.KotlinJvmTestBuilder.KOTLIN_STDLIB; +import static io.bazel.kotlin.builder.KotlinJvmTestBuilder.*; @RunWith(JUnit4.class) public class KotlinBuilderJvmKaptTest { private static final Dep AUTO_VALUE_ANNOTATIONS = Dep.importJar( - "autovalue", + "autovalue_annotations", "external/io_bazel_rules_kotlin_com_google_auto_value_auto_value_annotations" + "/jar/io_bazel_rules_kotlin_com_google_auto_value_auto_value_annotations.jar"); private static final Dep AUTO_VALUE = @@ -53,7 +52,7 @@ public class KotlinBuilderJvmKaptTest { private static final Consumer ADD_AUTO_VALUE_PLUGIN = (c) -> { c.addAnnotationProcessors(AUTO_VALUE_ANNOTATION_PROCESSOR); - c.addDirectDependencies(AUTO_VALUE_ANNOTATIONS, AUTO_VALUE, KOTLIN_STDLIB); + c.addDirectDependencies(AUTO_VALUE_ANNOTATIONS, KOTLIN_ANNOTATIONS, KOTLIN_STDLIB); }; @Test