diff --git a/kotlin/internal/jvm/compile.bzl b/kotlin/internal/jvm/compile.bzl index 671109533..0c63b89db 100644 --- a/kotlin/internal/jvm/compile.bzl +++ b/kotlin/internal/jvm/compile.bzl @@ -114,8 +114,8 @@ def _build_resourcejar_action(ctx): return resources_jar_output # MAIN ACTIONS ######################################################################################################### -def _declare_output_directory(ctx, aspect, dir_name): - return ctx.actions.declare_directory("_kotlinc/%s_%s/%s_%s" % (ctx.label.name, aspect, ctx.label.name, dir_name)) +def _output_dir_path(ctx, aspect, dir_name): + return "_kotlinc/%s_%s/%s_%s" % (ctx.label.name, aspect, ctx.label.name, dir_name) def _partition_srcs(srcs): """Partition sources for the jvm aspect.""" @@ -173,17 +173,17 @@ def kt_jvm_compile_action(ctx, rule_kind, output_jar): else: fail("only one friend is possible") - classes_directory = _declare_output_directory(ctx, "jvm", "classes") - generated_classes_directory = _declare_output_directory(ctx, "jvm", "generated_classes") - sourcegen_directory = _declare_output_directory(ctx, "jvm", "sourcegenfiles") - temp_directory = _declare_output_directory(ctx, "jvm", "temp") + classes_directory = _output_dir_path(ctx, "jvm", "classes") + generated_classes_directory = _output_dir_path(ctx, "jvm", "generated_classes") + sourcegen_directory = _output_dir_path(ctx, "jvm", "sourcegenfiles") + temp_directory = _output_dir_path(ctx, "jvm", "temp") args = _utils.init_args(ctx, rule_kind, module_name) - args.add("--classdir", classes_directory.path) - args.add("--sourcegendir", sourcegen_directory.path) - args.add("--tempdir", temp_directory.path) - args.add("--kotlin_generated_classdir", generated_classes_directory.path) + args.add("--classdir", classes_directory) + args.add("--sourcegendir", sourcegen_directory) + args.add("--tempdir", temp_directory) + args.add("--kotlin_generated_classdir", generated_classes_directory) args.add("--output", output_jar) args.add("--kotlin_output_jdeps", ctx.outputs.jdeps) @@ -222,10 +222,6 @@ def kt_jvm_compile_action(ctx, rule_kind, output_jar): output_jar, ctx.outputs.jdeps, ctx.outputs.srcjar, - sourcegen_directory, - classes_directory, - temp_directory, - generated_classes_directory, ], executable = toolchain.kotlinbuilder.files_to_run.executable, execution_requirements = {"supports-workers": "1"}, diff --git a/kotlin/internal/repositories/nomaven_repositories.bzl b/kotlin/internal/repositories/nomaven_repositories.bzl new file mode 100644 index 000000000..0232c85dc --- /dev/null +++ b/kotlin/internal/repositories/nomaven_repositories.bzl @@ -0,0 +1,57 @@ +# Copyright 2018 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""This file contains the Kotlin compiler repository definitions. It should not be loaded directly by client workspaces. +""" + +load( + "//kotlin/internal:defs.bzl", + _KT_COMPILER_REPO = "KT_COMPILER_REPO", +) +load( + "@bazel_tools//tools/build_defs/repo:http.bzl", + _http_archive = "http_archive", + _http_file = "http_file", +) + +BAZEL_JAVA_LAUNCHER_VERSION = "0.28.1" + +KOTLIN_CURRENT_COMPILER_RELEASE = { + "urls": [ + "https://github.com/JetBrains/kotlin/releases/download/v1.3.50/kotlin-compiler-1.3.50.zip", + ], + "sha256": "69424091a6b7f52d93eed8bba2ace921b02b113dbb71388d704f8180a6bdc6ec", +} + +def kotlin_repositories(compiler_release = KOTLIN_CURRENT_COMPILER_RELEASE): + """Call this in the WORKSPACE file to setup the Kotlin rules. + + Args: + compiler_release: (internal) dict containing "urls" and "sha256" for the Kotlin compiler. + """ + _http_archive( + name = _KT_COMPILER_REPO, + urls = compiler_release["urls"], + sha256 = compiler_release["sha256"], + build_file = "@io_bazel_rules_kotlin//kotlin/internal/repositories:BUILD.com_github_jetbrains_kotlin", + strip_prefix = "kotlinc", + ) + + _http_file( + name = "kt_java_stub_template", + urls = [("https://raw.githubusercontent.com/bazelbuild/bazel/" + + BAZEL_JAVA_LAUNCHER_VERSION + + "/src/main/java/com/google/devtools/build/lib/bazel/rules/java/" + + "java_stub_template.txt")], + sha256 = "e6531a6539ec1e38fec5e20523ff4bfc883e1cc0209eb658fe82eb918eb49657", + )