test refactor and replace moshi with protobuf, start model proto file
diff --git a/WORKSPACE b/WORKSPACE index 72bbc2a..91debff 100644 --- a/WORKSPACE +++ b/WORKSPACE
@@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. workspace(name="io_bazel_rules_kotlin") +load("//kotlin/internal:bootstrap.bzl", "github_archive") git_repository( name = "io_bazel_rules_sass", @@ -36,7 +37,6 @@ # test and example dependencies. maven_jar(name = "junit_junit",artifact = "junit:junit:jar:4.12") maven_jar(name = "autovalue", artifact="com.google.auto.value:auto-value:1.5") -maven_jar(name = "guava", artifact="com.google.guava:guava:24.0-jre") maven_jar(name = "auto_common", artifact="com.google.auto:auto-common:0.10") maven_jar(name = "autoservice", artifact="com.google.auto.service:auto-service:1.0-rc4") maven_jar(name = "javax_inject", artifact = "javax.inject:javax.inject:1") @@ -44,3 +44,5 @@ maven_jar(name = "dagger", artifact="com.google.dagger:dagger:2.9") maven_jar(name = "dagger_compiler", artifact="com.google.dagger:dagger-compiler:2.9") maven_jar(name = "dagger_producers", artifact="com.google.dagger:dagger-producers:2.9") + +maven_jar(name="com_google_truth_truth", artifact="com.google.truth:truth:0.40", sha1="0d74e716afec045cc4a178dbbfde2a8314ae5574")
diff --git a/examples/dagger/BUILD b/examples/dagger/BUILD index c68ec8e..17c4145 100644 --- a/examples/dagger/BUILD +++ b/examples/dagger/BUILD
@@ -19,7 +19,7 @@ name = "dagger_plugin", deps = [ "@dagger_compiler//jar", - "@guava//jar", + "@com_google_guava_guava//jar", "@dagger_producers//jar", "@dagger//jar", "@javax_inject//jar"
diff --git a/kotlin/builder/BUILD b/kotlin/builder/BUILD index 7ca7573..0fe8f78 100644 --- a/kotlin/builder/BUILD +++ b/kotlin/builder/BUILD
@@ -19,10 +19,10 @@ deps = [ "//kotlin/builder/proto", "@com_github_jetbrains_kotlin//:preloader", - "@io_bazel_rules_kotlin_protobuf_protobuf_java//jar", - "//third_party:okio", - "//third_party:moshi", - "//third_party:moshi-kotlin" + "@com_google_protobuf//:protobuf_java", + "@com_google_protobuf//:protobuf_java_util", + "@com_google_code_gson_gson//jar", + "@com_google_guava_guava//jar", ], exports = [ "//kotlin/builder/proto", @@ -46,6 +46,9 @@ name = "unittests", test_class = "io.bazel.kotlin.builder.mode.jvm.utils.JdepsParserTest", srcs = glob(["unittests/**/*.java"]), - deps = [":worker_lib"], + deps = [ + ":worker_lib", + "@com_google_protobuf//:protobuf_java" + ], size = "small" ) \ No newline at end of file
diff --git a/kotlin/builder/bootstrap.bzl b/kotlin/builder/bootstrap.bzl index 64db6f3..28cdfe4 100644 --- a/kotlin/builder/bootstrap.bzl +++ b/kotlin/builder/bootstrap.bzl
@@ -11,7 +11,7 @@ # 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. -load("//kotlin:kotlin.bzl", _for_ide = "kt_jvm_library") +load("//kotlin:kotlin.bzl", _for_ide = "kt_jvm_library", "kt_jvm_import") _HEADER = """ function join_by { local IFS="$$1"; shift; echo "$$*"; } @@ -56,7 +56,6 @@ exports = exports, visibility=["//visibility:private"], ) - native.filegroup( name = dep_label, srcs = deps, @@ -75,11 +74,21 @@ cmd = _gen_cmd(dep_label, " ".join(args)), visibility = ["//visibility:private"] ) - native.java_import( - name = libary_label, + + # Use kt_jvm_import so that ijarification doesn't ruin the worker lib. + kt_jvm_import( + name = libary_label + "_kt", jars = [jar_name], - exports = exports, + tags = ["no-ide"] + ) + + native.java_library( + name = libary_label, + exports = exports + [libary_label + "_kt"], runtime_deps = (depset(runtime_deps) + exports + deps).to_list(), - visibility = ["//visibility:private"], + visibility = [ + "//tests:__subpackages__", + "//kotlin:__subpackages__" + ], tags = ["no-ide"] ) \ No newline at end of file
diff --git a/kotlin/builder/proto/BUILD b/kotlin/builder/proto/BUILD index 367160c..210cf69 100644 --- a/kotlin/builder/proto/BUILD +++ b/kotlin/builder/proto/BUILD
@@ -11,13 +11,27 @@ # 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. + +_PROTO_LIBS=["deps", "worker_protocol", "kotlin_model"] + +[proto_library( + name="%s_proto" % lib, + srcs=["%s.proto" % lib] + ) for lib in _PROTO_LIBS] + +[java_proto_library( + name="%s_java_proto" % lib, + deps=["%s_proto" % lib], + visibility=["//visibility:private"] + ) for lib in _PROTO_LIBS] + java_import( name = "proto", jars = [ "jars/libdeps_proto-speed.jar", - "jars/libworker_protocol_proto-speed.jar" + "jars/libworker_protocol_proto-speed.jar", + "jars/libkotlin_model_proto-speed.jar" ], - exports = ["@io_bazel_rules_kotlin_protobuf_protobuf_java//jar"], visibility = ["//kotlin/builder:__subpackages__"] )
diff --git a/kotlin/builder/proto/gen_jars.sh b/kotlin/builder/proto/gen_jars.sh new file mode 100755 index 0000000..b6241ce --- /dev/null +++ b/kotlin/builder/proto/gen_jars.sh
@@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +WS_ROOT=$(bazel info workspace) +PATH_PROTO=kotlin/builder/proto +function build_lib() { +bazel build //${PATH_PROTO}:$1_java_proto +local FILE=lib$1_proto-speed.jar +cp ${WS_ROOT}/bazel-bin/${PATH_PROTO}/${FILE} ${WS_ROOT}/${PATH_PROTO}/jars/${FILE} +} + +build_lib "deps" +build_lib "worker_protocol" +build_lib "kotlin_model" + +chmod -R 0754 jars +
diff --git a/kotlin/builder/proto/jars/libdeps_proto-speed.jar b/kotlin/builder/proto/jars/libdeps_proto-speed.jar old mode 100644 new mode 100755 index 3437167..3749615 --- a/kotlin/builder/proto/jars/libdeps_proto-speed.jar +++ b/kotlin/builder/proto/jars/libdeps_proto-speed.jar Binary files differ
diff --git a/kotlin/builder/proto/jars/libkotlin_model_proto-speed.jar b/kotlin/builder/proto/jars/libkotlin_model_proto-speed.jar new file mode 100755 index 0000000..9bfc978 --- /dev/null +++ b/kotlin/builder/proto/jars/libkotlin_model_proto-speed.jar Binary files differ
diff --git a/kotlin/builder/proto/jars/libworker_protocol_proto-speed.jar b/kotlin/builder/proto/jars/libworker_protocol_proto-speed.jar index 69bc7fc..672d622 100755 --- a/kotlin/builder/proto/jars/libworker_protocol_proto-speed.jar +++ b/kotlin/builder/proto/jars/libworker_protocol_proto-speed.jar Binary files differ
diff --git a/kotlin/builder/proto/kotlin_model.proto b/kotlin/builder/proto/kotlin_model.proto new file mode 100644 index 0000000..efebc18 --- /dev/null +++ b/kotlin/builder/proto/kotlin_model.proto
@@ -0,0 +1,36 @@ +syntax = "proto3"; + +package bazel.kotlin; + +option java_package = "io.bazel.kotlin.model"; + +message AnnotationProcessor { + // the annotation processor class + string processor_class = 1; + // bazel `java_plugin` generates_api setting. + bool generates_api = 2; + // the classpath + repeated string classpath = 3; + + string label = 4; +} + +message CompilerPlugins { + repeated AnnotationProcessor annotation_processors = 1; +} + +message KotlinToolchainInfo { + message Common { + // mandatory + string language_version = 1; + //mandatory + string api_version = 2; + // oneof "enable", "warn" or "error" + string coroutines = 3; + } + + message Jvm { + // oneof "1.6", or "1.8" + string jvm_target = 4; + } +} \ No newline at end of file
diff --git a/kotlin/builder/src/io/bazel/kotlin/builder/Args.kt b/kotlin/builder/src/io/bazel/kotlin/builder/Args.kt index eb6bfb0..909a51b 100644 --- a/kotlin/builder/src/io/bazel/kotlin/builder/Args.kt +++ b/kotlin/builder/src/io/bazel/kotlin/builder/Args.kt
@@ -16,8 +16,6 @@ package io.bazel.kotlin.builder -import com.squareup.moshi.KotlinJsonAdapterFactory -import com.squareup.moshi.Moshi import java.nio.file.Files import java.nio.file.Paths @@ -48,14 +46,6 @@ fun ArgMap.mandatory(key: String): Array<String> = optional(key) ?: throw IllegalArgumentException("$key is not optional") fun ArgMap.optional(key: String): Array<String>? = this[key]?.toTypedArray() -inline fun <reified T : Any> ArgMap.mandatoryFromJson(key: String): T = optionalFromJson(key) ?: throw IllegalArgumentException("$key is not optional") -inline fun <reified T : Any> ArgMap.optionalFromJson(key: String): T? = optionalSingle(key)?.let { moshi.adapter(T::class.java).fromJson(it)!! } - -@PublishedApi -internal val moshi = Moshi.Builder().let { - it.add(KotlinJsonAdapterFactory()) - it.build() -} /** * Test if a flag is set
diff --git a/kotlin/builder/src/io/bazel/kotlin/builder/model/Flags.kt b/kotlin/builder/src/io/bazel/kotlin/builder/model/Flags.kt index f3e4e84..0af3e68 100644 --- a/kotlin/builder/src/io/bazel/kotlin/builder/model/Flags.kt +++ b/kotlin/builder/src/io/bazel/kotlin/builder/model/Flags.kt
@@ -15,7 +15,9 @@ */ package io.bazel.kotlin.builder.model +import com.google.protobuf.util.JsonFormat import io.bazel.kotlin.builder.* +import io.bazel.kotlin.model.KotlinModel /** * The flags supported by the worker. @@ -35,7 +37,13 @@ val sourceJars = argMap.optional(JavaBuilderFlags.SOURCE_JARS.flag) val classpath = argMap.mandatory(JavaBuilderFlags.CLASSPATH.flag) - val plugins = argMap.optionalFromJson<PluginDescriptors>("--kt-plugins") + val plugins: KotlinModel.CompilerPlugins? = argMap.optionalSingle("--kt-plugins")?.let { input -> + KotlinModel.CompilerPlugins.newBuilder().let { + jsonFormat.merge(input, it) + it.build() + } + } + val outputJdeps = argMap.mandatorySingle("--output_jdeps") val kotlinApiVersion = argMap.mandatorySingle("--kotlin_api_version") @@ -49,4 +57,13 @@ val kotlinPassthroughFlags = argMap.optionalSingle("--kotlin_passthrough_flags") val kotlinModuleName = argMap.optionalSingle("--kotlin_module_name") + + companion object { + @JvmStatic + private val jsonTypeRegistry = JsonFormat.TypeRegistry.newBuilder() + .add(KotlinModel.getDescriptor().messageTypes).build() + + @JvmStatic + private val jsonFormat = JsonFormat.parser().usingTypeRegistry(jsonTypeRegistry) + } } \ No newline at end of file
diff --git a/kotlin/builder/src/io/bazel/kotlin/builder/model/PluginDescriptors.kt b/kotlin/builder/src/io/bazel/kotlin/builder/model/PluginDescriptors.kt deleted file mode 100644 index 96a3323..0000000 --- a/kotlin/builder/src/io/bazel/kotlin/builder/model/PluginDescriptors.kt +++ /dev/null
@@ -1,35 +0,0 @@ -/* - * 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. - */ -package io.bazel.kotlin.builder.model - -import com.squareup.moshi.Json - -data class AnnotationProcessor( - @Json(name = "processor_class") val processorClass: String, - @Json(name = "generates_api") val generatesApi: Boolean, - @Json(name = "classpath") val classPath: List<String>, - @Json(name = "label") val labels: String -) - -/** - * Kotlin plugin descriptors - */ -data class PluginDescriptors( - /** - * The list of Annotation processors. - */ - val processors: List<AnnotationProcessor> -)
diff --git a/kotlin/builder/src/io/bazel/kotlin/builder/utils/PluginUtils.kt b/kotlin/builder/src/io/bazel/kotlin/builder/utils/PluginUtils.kt index 21c119c..616e299 100644 --- a/kotlin/builder/src/io/bazel/kotlin/builder/utils/PluginUtils.kt +++ b/kotlin/builder/src/io/bazel/kotlin/builder/utils/PluginUtils.kt
@@ -60,33 +60,30 @@ companion object { fun from(ctx: Context): List<String>? = - ctx.flags.plugins?.let { descriptor -> - if (descriptor.processors.isNotEmpty()) { - PluginArgs(ctx.toolchain.KAPT_PLUGIN).let { arg -> - arg["sources"] = ctx.flags.sourceGenDir.value.toString() - arg["classes"] = ctx.flags.classDir.value.toString() - arg["stubs"] = ctx.flags.tempDirPath.value.toString() - arg["incrementalData"] = ctx.flags.tempDirPath.value.toString() + ctx.flags.plugins?.takeIf { it.annotationProcessorsList.isNotEmpty() }?.let { plugin -> + PluginArgs(ctx.toolchain.KAPT_PLUGIN).let { arg -> + arg["sources"] = ctx.flags.sourceGenDir.value.toString() + arg["classes"] = ctx.flags.classDir.value.toString() + arg["stubs"] = ctx.flags.tempDirPath.value.toString() + arg["incrementalData"] = ctx.flags.tempDirPath.value.toString() - arg["aptMode"] = "stubsAndApt" - arg["correctErrorTypes"] = "true" -// arg["verbose"] = "true" + arg["aptMode"] = "stubsAndApt" + arg["correctErrorTypes"] = "true" +// arg["verbose"] = "true" - arg["processors"] = descriptor.processors - .filter { it.processorClass.isNotEmpty() } - .onEach { it.classPath.forEach { arg.bindMulti("apclasspath", it) } } - .joinToString(",") { it.processorClass } - - arg.encode() - } - } else null + arg["processors"] = plugin.annotationProcessorsList + .filter { it.processorClass.isNotEmpty() } + .onEach { it.classpathList.forEach { arg.bindMulti("apclasspath", it) } } + .joinToString(",") { it.processorClass } + arg.encode() } + } } } fun Context.annotationProcessingGeneratedSources(): Sequence<String>? = - if (flags.sourceGenDir.isInitialized()) { - flags.sourceGenDir.value.toFile().walkTopDown().filter { it.isFile }.map { it.path } - } else null + if (flags.sourceGenDir.isInitialized()) { + flags.sourceGenDir.value.toFile().walkTopDown().filter { it.isFile }.map { it.path } + } else null fun Context.annotationProcessingGeneratedJavaSources(): Sequence<String>? = annotationProcessingGeneratedSources()?.filter { it.endsWith(".java") } \ No newline at end of file
diff --git a/kotlin/internal/bootstrap.bzl b/kotlin/internal/bootstrap.bzl index 2513c40..65031b4 100644 --- a/kotlin/internal/bootstrap.bzl +++ b/kotlin/internal/bootstrap.bzl
@@ -54,3 +54,20 @@ toolchains = [kt.defs.TOOLCHAIN_TYPE], implementation = _kt_toolchain_ide_info_impl, ) + +def github_archive(name, repo, commit, build_file_content = None): + if build_file_content: + native.new_http_archive( + name = name, + strip_prefix = "%s-%s" % (repo.split("/")[1], commit), + url = "https://github.com/%s/archive/%s.zip" % (repo, commit), + type = "zip", + build_file_content = build_file_content, + ) + else: + native.http_archive( + name = name, + strip_prefix = "%s-%s" % (repo.split("/")[1], commit), + url = "https://github.com/%s/archive/%s.zip" % (repo, commit), + type = "zip", + )
diff --git a/kotlin/internal/compile.bzl b/kotlin/internal/compile.bzl index 913ab40..d3049f2 100644 --- a/kotlin/internal/compile.bzl +++ b/kotlin/internal/compile.bzl
@@ -68,7 +68,7 @@ # Collect and prepare plugin descriptor for the worker. plugin_info=plugins.merge_plugin_infos(ctx.attr.plugins + ctx.attr.deps) - if len(plugin_info.processors) > 0: + if len(plugin_info.annotation_processors) > 0: args += [ "--kt-plugins", plugin_info.to_json() ] # Declare and write out argument file.
diff --git a/kotlin/internal/kt.bzl b/kotlin/internal/kt.bzl index 47e1985..187e077 100644 --- a/kotlin/internal/kt.bzl +++ b/kotlin/internal/kt.bzl
@@ -32,7 +32,7 @@ _KtPluginInfo = provider( fields = { - "processors": "a serializeable list of structs containing an annotation processor definitions", + "annotation_processors": "a serializeable list of structs containing an annotation processor definitions", }, )
diff --git a/kotlin/internal/plugins.bzl b/kotlin/internal/plugins.bzl index 85ed686..937d180 100644 --- a/kotlin/internal/plugins.bzl +++ b/kotlin/internal/plugins.bzl
@@ -23,13 +23,13 @@ def _merge_plugin_infos(attrs): tally={} - processors=[] + annotation_processors=[] for info in [a[kt.info.KtPluginInfo] for a in attrs]: - for p in info.processors: + for p in info.annotation_processors: if p.label not in tally: tally[p.label] = True - processors.append(p) - return kt.info.KtPluginInfo(processors=processors) + annotation_processors.append(p) + return kt.info.KtPluginInfo(annotation_processors=annotation_processors) def _restore_label(l): lbl = l.workspace_root @@ -37,12 +37,12 @@ lbl = lbl.replace("external/", "@") return lbl + "//" + l.package + ":" + l.name -_EMPTY_PLUGIN_INFO = [kt.info.KtPluginInfo(processors = [])] +_EMPTY_PLUGIN_INFO = [kt.info.KtPluginInfo(annotation_processors = [])] def _kt_jvm_plugin_aspect_impl(target, ctx): if ctx.rule.kind == "java_plugin": return [kt.info.KtPluginInfo( - processors = [_mk_processor_entry(_restore_label(ctx.label),ctx.rule.attr)] + annotation_processors = [_mk_processor_entry(_restore_label(ctx.label),ctx.rule.attr)] )] else: if ctx.rule.kind == "java_library":
diff --git a/kotlin/kotlin_compiler_repositories.bzl b/kotlin/kotlin_compiler_repositories.bzl index d9d1976..03cb06c 100644 --- a/kotlin/kotlin_compiler_repositories.bzl +++ b/kotlin/kotlin_compiler_repositories.bzl
@@ -18,6 +18,9 @@ "//kotlin/internal:kt.bzl", _kt = "kt", ) +load("//kotlin/internal:bootstrap.bzl", + _github_archive="github_archive" +) KOTLIN_RELEASES = { "1.2.41": { @@ -168,7 +171,10 @@ _BAZEL_JAVA_LAUNCHER_VERSION = "0.8.1" def kotlin_compiler_repository( - kotlin_release_version=KOTLIN_CURRENT_RELEASE + kotlin_release_version=KOTLIN_CURRENT_RELEASE, + omit_com_google_protobuf=False, + omit_com_google_code_gson_gson=False, + omit_com_google_guava_guava=False, ): release=KOTLIN_RELEASES[kotlin_release_version] if not release: @@ -182,12 +188,6 @@ strip_prefix = "kotlinc", ) - native.maven_jar( - name = "io_bazel_rules_kotlin_protobuf_protobuf_java", - artifact = "com.google.protobuf:protobuf-java:3.4.0", - sha1 = "b32aba0cbe737a4ca953f71688725972e3ee927c", - ) - native.http_file( name = "kt_java_stub_template", url = ("https://raw.githubusercontent.com/bazelbuild/bazel/" + @@ -195,4 +195,37 @@ "/src/main/java/com/google/devtools/build/lib/bazel/rules/java/" + "java_stub_template.txt"), sha256 = "86660ee7d5b498ccf611a1e000564f45268dbf301e0b2b08c984dcecc6513f6e", - ) \ No newline at end of file + ) + + if not omit_com_google_guava_guava: + com_google_guava_guava() + if not omit_com_google_code_gson_gson: + com_google_code_gson_gson() + if not omit_com_google_protobuf: + com_google_protobuf() + + +def com_google_protobuf(): + _github_archive( + name = "com_google_protobuf", + repo = "google/protobuf", + commit = "106ffc04be1abf3ff3399f54ccf149815b287dd9", + ) + +def com_google_code_gson_gson(): + native.maven_jar( + name = "com_google_code_gson_gson", + artifact = "com.google.code.gson:gson:2.8.4", + sha1 = "d0de1ca9b69e69d1d497ee3c6009d015f64dad57" + ) + native.bind(name="gson", actual="@com_google_code_gson_gson//jar") + +def com_google_guava_guava(): + native.maven_jar( + name = "com_google_guava_guava", + artifact = "com.google.guava:guava:25.0-jre", + sha1 = "7319c34fa5866a85b6bad445adad69d402323129" + ) + native.bind(name="guava", actual="@com_google_guava_guava//jar") + +
diff --git a/tests/integrationtests/BUILD b/tests/integrationtests/BUILD index 3bb04b7..c0356b1 100644 --- a/tests/integrationtests/BUILD +++ b/tests/integrationtests/BUILD
@@ -11,6 +11,8 @@ # 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. +package(default_visibility=["//tests/integrationtests:__subpackages__"]) + test_suite( name = "integrationtests", tests=[
diff --git a/tests/integrationtests/jvm/BUILD b/tests/integrationtests/jvm/BUILD index fe6458f..2a56567 100644 --- a/tests/integrationtests/jvm/BUILD +++ b/tests/integrationtests/jvm/BUILD
@@ -13,18 +13,17 @@ # limitations under the License. package(default_visibility=["//visibility:private"]) # The tests are written in Kotlin, so the tests inately test a lot of the rule functionality. -load("//tests/integrationtests/lib:kt_it_assertion_test.bzl", "kt_it_assertion_test") - +load("//tests/rules:defs.bzl", "kt_it_assertion_test") kt_it_assertion_test( name = "basic_tests", cases="//tests/integrationtests/jvm/basic:cases", - test_class="io.bazel.ruleskotlin.integrationtests.jvm.JvmBasicIntegrationTests", + test_class="io.bazel.kotlin.testing.jvm.JvmBasicFunctionalTests", ) kt_it_assertion_test( name = "annoation_processing_tests", cases = "//tests/integrationtests/jvm/kapt:cases", - test_class="io.bazel.ruleskotlin.integrationtests.jvm.JvmAnnotationProcessingIntegrationTests", + test_class="io.bazel.kotlin.testing.jvm.JvmAnnotationProcessingFunctionalTests", data = [ "//examples/dagger:coffee_app"] )
diff --git a/tests/integrationtests/jvm/JvmAnnotationProcessingIntegrationTests.kt b/tests/integrationtests/jvm/JvmAnnotationProcessingFunctionalTests.kt similarity index 94% rename from tests/integrationtests/jvm/JvmAnnotationProcessingIntegrationTests.kt rename to tests/integrationtests/jvm/JvmAnnotationProcessingFunctionalTests.kt index 9a26987..1b3fbfe 100644 --- a/tests/integrationtests/jvm/JvmAnnotationProcessingIntegrationTests.kt +++ b/tests/integrationtests/jvm/JvmAnnotationProcessingFunctionalTests.kt
@@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.bazel.ruleskotlin.integrationtests.jvm +package io.bazel.kotlin.testing.jvm -import io.bazel.ruleskotlin.integrationtests.lib.AssertionTestCase +import io.bazel.kotlin.testing.AssertionTestCase import org.junit.Test -class JvmAnnotationProcessingIntegrationTests : AssertionTestCase("tests/integrationtests/jvm/kapt") { +class JvmAnnotationProcessingFunctionalTests : AssertionTestCase("tests/integrationtests/jvm/kapt") { @Test fun testKotlinOnlyAnnotationProcessing() { jarTestCase("ap_kotlin.jar", description = "annotation processing should work") {
diff --git a/tests/integrationtests/jvm/JvmBasicIntegrationTests.kt b/tests/integrationtests/jvm/JvmBasicFunctionalTests.kt similarity index 93% rename from tests/integrationtests/jvm/JvmBasicIntegrationTests.kt rename to tests/integrationtests/jvm/JvmBasicFunctionalTests.kt index e20afe9..a92835a 100644 --- a/tests/integrationtests/jvm/JvmBasicIntegrationTests.kt +++ b/tests/integrationtests/jvm/JvmBasicFunctionalTests.kt
@@ -13,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.bazel.ruleskotlin.integrationtests.jvm +package io.bazel.kotlin.testing.jvm -import io.bazel.ruleskotlin.integrationtests.lib.AssertionTestCase +import io.bazel.kotlin.testing.AssertionTestCase import org.junit.Test -class JvmBasicIntegrationTests : AssertionTestCase("tests/integrationtests/jvm/basic") { +class JvmBasicFunctionalTests : AssertionTestCase("tests/integrationtests/jvm/basic") { @Test fun testResourceMerging() { jarTestCase("test_embed_resources.jar", description = "The rules should support including resource directories") {
diff --git a/tests/integrationtests/jvm/kapt/BUILD b/tests/integrationtests/jvm/kapt/BUILD index b20b33a..f1670dc 100644 --- a/tests/integrationtests/jvm/kapt/BUILD +++ b/tests/integrationtests/jvm/kapt/BUILD
@@ -25,7 +25,7 @@ name = "autoservice", deps = [ "@autoservice//jar", - "@guava//jar", + "@com_google_guava_guava//jar", "@auto_common//jar" ], processor_class = "com.google.auto.service.processor.AutoServiceProcessor",
diff --git a/tests/integrationtests/lib/AssertionTestCase.kt b/tests/rules/AssertionTestCase.kt similarity index 98% rename from tests/integrationtests/lib/AssertionTestCase.kt rename to tests/rules/AssertionTestCase.kt index 1366e43..a701762 100644 --- a/tests/integrationtests/lib/AssertionTestCase.kt +++ b/tests/rules/AssertionTestCase.kt
@@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package io.bazel.ruleskotlin.integrationtests.lib +package io.bazel.kotlin.testing import java.io.File import java.nio.file.Path
diff --git a/tests/integrationtests/lib/BUILD b/tests/rules/BUILD similarity index 83% rename from tests/integrationtests/lib/BUILD rename to tests/rules/BUILD index 072083d..704c08e 100644 --- a/tests/integrationtests/lib/BUILD +++ b/tests/rules/BUILD
@@ -11,13 +11,13 @@ # 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. -package(default_visibility=["//tests/integrationtests:__subpackages__"]) +package(default_visibility=["//tests:__subpackages__"]) load("//kotlin:kotlin.bzl", "kt_jvm_library") kt_jvm_library( - name = "lib", + name = "assertion_test_case", srcs = ["AssertionTestCase.kt"], - visibility=["//tests/integrationtests:__subpackages__"], + visibility=["//tests:__subpackages__"], deps=["@com_github_jetbrains_kotlin//:kotlin-test"], testonly=1 ) \ No newline at end of file
diff --git a/tests/integrationtests/lib/kt_it_assertion_test.bzl b/tests/rules/defs.bzl similarity index 84% rename from tests/integrationtests/lib/kt_it_assertion_test.bzl rename to tests/rules/defs.bzl index 1361109..f30a2d2 100644 --- a/tests/integrationtests/lib/kt_it_assertion_test.bzl +++ b/tests/rules/defs.bzl
@@ -13,12 +13,18 @@ # limitations under the License. load("//kotlin:kotlin.bzl", "kt_jvm_test") +_TEST_COMMON_DEPS=[ + "//tests/rules:assertion_test_case", + "@junit_junit//jar", + "@com_google_truth_truth//jar" +] + def kt_it_assertion_test(name, cases, test_class, data = [], deps=[]): parts=test_class.split(".") kt_jvm_test( name=name, srcs=["%s.kt" % parts[len(parts)-1]], - deps = ["//tests/integrationtests/lib:lib", "@junit_junit//jar"] + deps, + deps = _TEST_COMMON_DEPS + deps, test_class=test_class, data=[cases] + data, visibility=["//visibility:private"]
diff --git a/third_party/BUILD b/third_party/BUILD deleted file mode 100644 index 3768ada..0000000 --- a/third_party/BUILD +++ /dev/null
@@ -1,5 +0,0 @@ -package(default_visibility=["//visibility:public"]) - -java_import(name = "okio", jars = ["okio/okio-1.13.0.jar"]) -java_import(name = "moshi",jars = ["moshi/moshi-1.5.0.jar"], exports = [":okio", ":moshi-kotlin"]) -java_import(name = "moshi-kotlin", jars = ["moshi/moshi-kotlin-1.5.0.jar"]) \ No newline at end of file
diff --git a/third_party/moshi/LICENSE b/third_party/moshi/LICENSE deleted file mode 100644 index 835428f..0000000 --- a/third_party/moshi/LICENSE +++ /dev/null
@@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - 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. \ No newline at end of file
diff --git a/third_party/moshi/moshi-1.5.0.jar b/third_party/moshi/moshi-1.5.0.jar deleted file mode 100644 index c7ee73d..0000000 --- a/third_party/moshi/moshi-1.5.0.jar +++ /dev/null Binary files differ
diff --git a/third_party/moshi/moshi-kotlin-1.5.0.jar b/third_party/moshi/moshi-kotlin-1.5.0.jar deleted file mode 100644 index e3d97bd..0000000 --- a/third_party/moshi/moshi-kotlin-1.5.0.jar +++ /dev/null Binary files differ
diff --git a/third_party/okio/LICENSE b/third_party/okio/LICENSE deleted file mode 100644 index 835428f..0000000 --- a/third_party/okio/LICENSE +++ /dev/null
@@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - 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. \ No newline at end of file
diff --git a/third_party/okio/okio-1.13.0.jar b/third_party/okio/okio-1.13.0.jar deleted file mode 100644 index 02c302f..0000000 --- a/third_party/okio/okio-1.13.0.jar +++ /dev/null Binary files differ