Skip to content

Commit

Permalink
Merged to head
Browse files Browse the repository at this point in the history
  • Loading branch information
Corbin Smith committed May 16, 2020
1 parent 02d6b78 commit e6b7f1b
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 50 deletions.
3 changes: 2 additions & 1 deletion docs/kotlin.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ kt_jvm_test(<a href="#kt_jvm_test-name">name</a>, <a href="#kt_jvm_test-data">da
## define_kt_toolchain

<pre>
define_kt_toolchain(<a href="#define_kt_toolchain-name">name</a>, <a href="#define_kt_toolchain-language_version">language_version</a>, <a href="#define_kt_toolchain-api_version">api_version</a>, <a href="#define_kt_toolchain-jvm_target">jvm_target</a>)
define_kt_toolchain(<a href="#define_kt_toolchain-name">name</a>, <a href="#define_kt_toolchain-language_version">language_version</a>, <a href="#define_kt_toolchain-api_version">api_version</a>, <a href="#define_kt_toolchain-jvm_target">jvm_target</a>, <a href="#define_kt_toolchain-experimental_use_abi_jars">experimental_use_abi_jars</a>)
</pre>

Define the Kotlin toolchain.
Expand All @@ -277,6 +277,7 @@ Define the Kotlin toolchain.
| language_version | <p align="center"> - </p> | <code>None</code> |
| api_version | <p align="center"> - </p> | <code>None</code> |
| jvm_target | <p align="center"> - </p> | <code>None</code> |
| experimental_use_abi_jars | <p align="center"> - </p> | <code>False</code> |


<a name="#kt_android_library"></a>
Expand Down
12 changes: 12 additions & 0 deletions kotlin/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,16 @@ stardoc(
deps = [
"kotlin",
],
symbol_names = [
"define_kt_toolchain",
"kt_js_library",
"kt_js_import",
"kt_register_toolchains",
"kt_jvm_binary",
"kt_jvm_import",
"kt_jvm_library",
"kt_jvm_test",
"kt_android_library",
"kt_compiler_plugin",
]
)
3 changes: 3 additions & 0 deletions kotlin/internal/jvm/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ bzl_library(
name = "jvm",
srcs = glob(["*.bzl"]),
visibility = ["//kotlin:__subpackages__"],
deps = [
"//third_party:java_tools_bzl",
]
)
1 change: 1 addition & 0 deletions kotlin/internal/repositories/download.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def kt_download_local_dev_dependencies():
url = "https://github.com/bazelbuild/rules_pkg/releases/download/0.2.4/rules_pkg-0.2.4.tar.gz",
sha256 = "4ba8f4ab0ff85f2484287ab06c0d871dcb31cc54d439457d28fd4ae14b18450a",
)

maybe(
git_repository,
name = "io_bazel_stardoc",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@
import io.bazel.kotlin.builder.tasks.js.Kotlin2JsTaskExecutor;
import io.bazel.kotlin.builder.tasks.jvm.KotlinJvmTaskExecutor;
import io.bazel.kotlin.builder.tasks.jvm.KtAbiPluginArgs;
import io.bazel.kotlin.builder.toolchain.KotlinCompilerPluginArgsEncoder;
import io.bazel.kotlin.builder.toolchain.KaptCompilerPluginArgsEncoder;
import io.bazel.kotlin.builder.toolchain.KotlinToolchain;
import java.io.PrintStream;

import javax.inject.Singleton;
import java.io.PrintStream;

@Singleton
@dagger.Component(modules = {KotlinBuilderComponent.Module.class})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ fun JvmCompilationTask.compileKotlin(
if (inputs.kotlinSourcesList.isEmpty()) {
return emptyList()
} else {
return pluginArgs(args, this)
return pluginArgs(this, args)
.values(inputs.javaSourcesList)
.values(inputs.kotlinSourcesList)
.list().let {
Expand Down
48 changes: 22 additions & 26 deletions src/test/kotlin/io/bazel/kotlin/builder/KotlinJvmTestBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@

public final class KotlinJvmTestBuilder extends KotlinAbstractTestBuilder<JvmCompilationTask> {

@SuppressWarnings({"unused", "WeakerAccess"})
public static Dep
KOTLIN_ANNOTATIONS = Dep.fromLabel("@com_github_jetbrains_kotlin//:annotations"),
KOTLIN_STDLIB = Dep.fromLabel("@com_github_jetbrains_kotlin//:kotlin-stdlib"),
KOTLIN_STDLIB_JDK7 = Dep.fromLabel("@com_github_jetbrains_kotlin//:kotlin-stdlib-jdk7"),
KOTLIN_STDLIB_JDK8 = Dep.fromLabel("@com_github_jetbrains_kotlin//:kotlin-stdlib-jdk8"),
JVM_ABI_GEN = Dep.fromLabel("@com_github_jetbrains_kotlin//:jvm-abi-gen");
@SuppressWarnings({"unused", "WeakerAccess"})
public static Dep
KOTLIN_ANNOTATIONS = Dep.fromLabel("@com_github_jetbrains_kotlin//:annotations"),
KOTLIN_STDLIB = Dep.fromLabel("@com_github_jetbrains_kotlin//:kotlin-stdlib"),
KOTLIN_STDLIB_JDK7 = Dep.fromLabel("@com_github_jetbrains_kotlin//:kotlin-stdlib-jdk7"),
KOTLIN_STDLIB_JDK8 = Dep.fromLabel("@com_github_jetbrains_kotlin//:kotlin-stdlib-jdk8"),
JVM_ABI_GEN = Dep.fromLabel("@com_github_jetbrains_kotlin//:jvm-abi-gen");

private static final JvmCompilationTask.Builder taskBuilder = JvmCompilationTask.newBuilder();
private static final EnumSet<DirectoryType> ALL_DIRECTORY_TYPES =
Expand All @@ -50,12 +50,7 @@ public final class KotlinJvmTestBuilder extends KotlinAbstractTestBuilder<JvmCom
DirectoryType.SOURCE_GEN,
DirectoryType.GENERATED_CLASSES,
DirectoryType.TEMP);
@SuppressWarnings({"unused", "WeakerAccess"})
public static Dep
KOTLIN_ANNOTATIONS = Dep.fromLabel("@com_github_jetbrains_kotlin//:annotations"),
KOTLIN_STDLIB = Dep.fromLabel("@com_github_jetbrains_kotlin//:kotlin-stdlib"),
KOTLIN_STDLIB_JDK7 = Dep.fromLabel("@com_github_jetbrains_kotlin//:kotlin-stdlib-jdk7"),
KOTLIN_STDLIB_JDK8 = Dep.fromLabel("@com_github_jetbrains_kotlin//:kotlin-stdlib-jdk8");

private TaskBuilder taskBuilderInstance = new TaskBuilder();

@Override
Expand All @@ -74,7 +69,7 @@ void setupForNext(CompilationTaskInfo.Builder taskInfo) {
}

@Override
JvmCompilationTask buildTask() {
JvmCompilationTask buildTask() {
return taskBuilder.build();
}

Expand All @@ -83,8 +78,8 @@ public final Dep runCompileTask(Consumer<TaskBuilder>... setup) {
return executeTask(component().jvmTaskExecutor()::execute, setup);
}

public static KotlinBuilderTestComponent component() {
return DaggerKotlinBuilderTestComponent.builder()
public static KotlinBuilderTestComponent component() {
return DaggerKotlinBuilderTestComponent.builder()
.toolchain(KotlinToolchain.createToolchain())
.build();
}
Expand All @@ -101,7 +96,7 @@ private Dep executeTask(
JvmCompilationTask.Outputs outputs = task.getOutputs();
assertFilesExist(
Stream.of(
outputs.getAbijar(),
outputs.getAbijar(),
outputs.getJar(),
outputs.getJdeps(),
outputs.getSrcjar())
Expand All @@ -111,17 +106,18 @@ private Dep executeTask(

return Dep.builder()
.label(taskBuilder.getInfo().getLabel())
.compileJars(ImmutableList.of(
outputs.getAbijar().isEmpty() ? outputs.getJar() : outputs.getAbijar()
))
.compileJars(ImmutableList.of(
outputs.getAbijar().isEmpty() ? outputs.getJar() : outputs.getAbijar()
))
.runtimeDeps(ImmutableList.copyOf(taskBuilder.getInputs().getClasspathList()))
.sourceJar(taskBuilder.getOutputs().getSrcjar())
.build();
});
}

public class TaskBuilder {
TaskBuilder() {}
TaskBuilder() {
}

public void setLabel(String label) {
taskBuilder.getInfoBuilder().setLabel(label);
Expand Down Expand Up @@ -176,10 +172,10 @@ public TaskBuilder outputJdeps() {
return this;
}

public TaskBuilder outputAbiJar() {
taskBuilder.getOutputsBuilder()
.setAbijar(instanceRoot().resolve("abi.jar").toAbsolutePath().toString());
return this;
}
public TaskBuilder outputAbiJar() {
taskBuilder.getOutputsBuilder()
.setAbijar(instanceRoot().resolve("abi.jar").toAbsolutePath().toString());
return this;
}
}
}
21 changes: 1 addition & 20 deletions src/test/kotlin/io/bazel/kotlin/builder/tasks/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,7 @@ kt_rules_test(
)

kt_rules_test(
name = "KotlinWorkerTest",
srcs = ["jvm/KotlinWorkerTest.kt"],
)

kt_rules_test(
name = "KotlinBuilderJavabiTest",
name = "KotlinBuilderJvmJavaTest",
srcs = ["jvm/KotlinBuilderJvmJavaTest.java"],
)

Expand Down Expand Up @@ -63,20 +58,6 @@ kt_jvm_test(
]
)

kt_jvm_test(
name = "BazelWorkerTest",
srcs = ["BazelWorkerTest.kt"],
test_class = "io.bazel.kotlin.builder.tasks.BazelWorkerTest",
deps = [
"//src/main/kotlin/io/bazel/kotlin/builder/tasks:tasks",
"//src/test/kotlin/io/bazel/kotlin/builder:test_lib",
artifact("org.jetbrains.kotlinx:kotlinx-coroutines-core", repository_name="kotlin_rules_maven"),
artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test", repository_name="kotlin_rules_maven"),
artifact("org.jetbrains.kotlinx:kotlinx-coroutines-debug", repository_name="kotlin_rules_maven"),
]
)


# TODO(bazelbuild/rules_kotlin/issues/275): Remove full jar reference when the kt_rules_test handles jvm_import data better.
_MAVEN_CENTRAL_PREFIX = "@kotlin_rules_maven//:v1/https/maven-central.storage.googleapis.com/repos/central/data"

Expand Down
7 changes: 7 additions & 0 deletions third_party/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package(default_visibility = ["//visibility:public"])
load("@rules_java//java:defs.bzl", "java_binary", "java_library", "java_plugin")
load("//kotlin:kotlin.bzl", "kt_jvm_import")
load("//kotlin/internal/utils:packager.bzl", "release_archive")
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")

exports_files(["empty.jar"])

Expand Down Expand Up @@ -68,6 +69,12 @@ java_import(
visibility = ["//visibility:public"],
)


bzl_library(
name = "java_tools_bzl",
srcs = ["@bazel_tools//tools:bzl_srcs"],
)

release_archive(
name = "pkg",
srcs = ["empty.jar"],
Expand Down

0 comments on commit e6b7f1b

Please sign in to comment.