Skip to content

Commit

Permalink
Update Bazel to 3.7.1 and use Kotlin toolchain 1.4.
Browse files Browse the repository at this point in the history
Additionally, update the Dagger compiler tests that verify Guava is not in the classpath by using the newer .withClasspath() API along with additionally filtering out Bazel's runner deploy jar which leaks Guava classes into the compile testing classpath.

RELNOTES=n/a
PiperOrigin-RevId: 345731509
  • Loading branch information
java-team-github-bot authored and Dagger Team committed Dec 4, 2020
1 parent c87ef43 commit b5990a0
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ env:
# permission to push to the repo.
- secure: "UpTUhCQzAGbr5JetRg2GZxp/dPDep/7Il3yGeyDECopciWdx41OPk/QNqAXBhNtKuEaMVsmASyoteuhgaTryQdV4qUIGVOMhES6kbOlYy3nwK44VdsNeeepwVospyDyZbxMtXq5LuHWuTADmAl1mdjNPNoziXc523zjnUzUx/EQ="
- JDK_FOR_PUBLISHING: *jdk_for_publishing
- BAZEL_VERSION="2.2.0"
- BAZEL_VERSION="3.7.1"

after_success:
- util/generate-latest-docs.sh
Expand Down
8 changes: 8 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,17 @@
load("@rules_java//java:defs.bzl", "java_library")
load("@google_bazel_common//tools/javadoc:javadoc.bzl", "javadoc_library")
load("@google_bazel_common//tools/jarjar:jarjar.bzl", "jarjar_library")
load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "define_kt_toolchain")

package(default_visibility = ["//visibility:public"])

define_kt_toolchain(
name = "kotlin_toolchain",
api_version = "1.4",
jvm_target = "1.8",
language_version = "1.4",
)

package_group(
name = "src",
packages = ["//..."],
Expand Down
49 changes: 32 additions & 17 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,37 @@ http_archive(
urls = ["https://github.com/madler/zlib/archive/v1.2.11.tar.gz"],
)

RULES_KOTLIN_COMMIT = "2c283821911439e244285b5bfec39148e7d90e21"

RULES_KOTLIN_SHA = "b04cd539e7e3571745179da95069586b6fa76a64306b24bb286154e652010608"

http_archive(
name = "io_bazel_rules_kotlin",
sha256 = RULES_KOTLIN_SHA,
strip_prefix = "rules_kotlin-%s" % RULES_KOTLIN_COMMIT,
type = "zip",
urls = ["https://github.com/bazelbuild/rules_kotlin/archive/%s.zip" % RULES_KOTLIN_COMMIT],
)

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

kt_download_local_dev_dependencies()

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

KOTLIN_VERSION = "1.4.20"

KOTLINC_RELEASE_SHA = "11db93a4d6789e3406c7f60b9f267eba26d6483dcd771eff9f85bb7e9837011f"

KOTLINC_RELEASE = {
"sha256": KOTLINC_RELEASE_SHA,
"urls": ["https://github.com/JetBrains/kotlin/releases/download/v{v}/kotlin-compiler-{v}.zip".format(v = KOTLIN_VERSION)],
}

kotlin_repositories(compiler_release = KOTLINC_RELEASE)

register_toolchains("//:kotlin_toolchain")

load("@rules_jvm_external//:defs.bzl", "maven_install")

ANDROID_LINT_VERSION = "26.6.2"
Expand Down Expand Up @@ -95,7 +126,7 @@ maven_install(
"com.android.tools:testutils:%s" % ANDROID_LINT_VERSION,
"com.github.tschuchortdev:kotlin-compile-testing:1.2.8",
"com.google.guava:guava:27.1-android",
"org.jetbrains.kotlin:kotlin-stdlib:1.3.50",
"org.jetbrains.kotlin:kotlin-stdlib:%s" % KOTLIN_VERSION,
"org.jetbrains.kotlinx:kotlinx-metadata-jvm:0.1.0",
"org.robolectric:robolectric:4.3.1",
],
Expand All @@ -106,22 +137,6 @@ maven_install(
],
)

RULES_KOTLIN_VERSION = "legacy-1.4.0-rc3"

RULES_KOTLIN_SHA = "da0e6e1543fcc79e93d4d93c3333378f3bd5d29e82c1bc2518de0dbe048e6598"

http_archive(
name = "io_bazel_rules_kotlin",
sha256 = RULES_KOTLIN_SHA,
urls = ["https://github.com/bazelbuild/rules_kotlin/releases/download/%s/rules_kotlin_release.tgz" % RULES_KOTLIN_VERSION],
)

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

kotlin_repositories()

kt_register_toolchains()

BAZEL_SKYLIB_VERSION = "1.0.2"

BAZEL_SKYLIB_SHA = "97e70364e9249702246c0e9444bccdc4b847bed1eb03c5a3ece4f83dfe6abc44"
Expand Down
18 changes: 11 additions & 7 deletions javatests/dagger/internal/codegen/Compilers.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,29 @@
import static com.google.common.base.StandardSystemProperty.JAVA_CLASS_PATH;
import static com.google.common.base.StandardSystemProperty.PATH_SEPARATOR;
import static com.google.testing.compile.Compiler.javac;
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.collectingAndThen;
import static java.util.stream.Collectors.toList;

import com.google.auto.value.processor.AutoAnnotationProcessor;
import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableList;
import com.google.testing.compile.Compiler;
import java.io.File;
import java.util.Arrays;
import javax.annotation.processing.Processor;

/** {@link Compiler} instances for testing Dagger. */
public final class Compilers {
private static final String GUAVA = "guava";

static final ImmutableList<String> CLASS_PATH_WITHOUT_GUAVA_OPTION =
ImmutableList.of(
"-classpath",
Splitter.on(PATH_SEPARATOR.value()).splitToList(JAVA_CLASS_PATH.value()).stream()
.filter(jar -> !jar.contains(GUAVA))
.collect(joining(PATH_SEPARATOR.value())));
static final ImmutableList<File> CLASS_PATH_WITHOUT_GUAVA_OPTION =
Splitter.on(PATH_SEPARATOR.value()).splitToList(JAVA_CLASS_PATH.value()).stream()
.filter(jar -> !jar.contains(GUAVA))
// Remove Bazel's runner deploy jar which leaks Guava classes into the classpath and
// the compile testing tests.
.filter(jar -> !jar.contains("Runner_deploy.jar"))
.map(File::new)
.collect(collectingAndThen(toList(), ImmutableList::copyOf));

static final ImmutableList<String> DEFAULT_JAVACOPTS =
ImmutableList.of("-Adagger.experimentalDaggerErrorMessages=enabled");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ public void subcomponentOmitsInheritedBindings() {
}

private Compiler daggerCompilerWithoutGuava() {
return compilerWithOptions(compilerMode.javacopts().append(CLASS_PATH_WITHOUT_GUAVA_OPTION));
return compilerWithOptions(compilerMode.javacopts())
.withClasspath(CLASS_PATH_WITHOUT_GUAVA_OPTION);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ public void subcomponentOmitsInheritedBindings() {
}

private Compiler daggerCompilerWithoutGuava() {
return compilerWithOptions(compilerMode.javacopts().append(CLASS_PATH_WITHOUT_GUAVA_OPTION));
return compilerWithOptions(compilerMode.javacopts())
.withClasspath(CLASS_PATH_WITHOUT_GUAVA_OPTION);
}
}

0 comments on commit b5990a0

Please sign in to comment.