Skip to content

Commit

Permalink
Update external dependencies for Java 17 support
Browse files Browse the repository at this point in the history
Update the following dependencies to newer versions so they work with
Java 17:
* mockito
* apache commons-lang3
* zookeeper
* jackson

Some tests were updated to work with newer version of mockito.

Update Bazel to version 6.5.0 and pull in new version of rules_java to
use the latest JDK for compilation.
  • Loading branch information
rohagarwal committed Mar 29, 2024
1 parent 176ad2d commit da8134f
Show file tree
Hide file tree
Showing 23 changed files with 186 additions and 217 deletions.
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.1.1
6.5.0
1 change: 1 addition & 0 deletions 3rdparty/jvm/com/fasterxml/jackson/core/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ java_library(
runtime_deps = [
":jackson_annotations",
":jackson_core",
"//3rdparty/jvm/net/bytebuddy:byte_buddy",
],
)
1 change: 1 addition & 0 deletions 3rdparty/jvm/com/fasterxml/jackson/dataformat/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ java_library(
],
runtime_deps = [
"//3rdparty/jvm/com/fasterxml/jackson/core:jackson_core",
"//3rdparty/jvm/com/fasterxml/jackson/core:jackson_databind",
"//3rdparty/jvm/org/yaml:snakeyaml",
],
)
17 changes: 1 addition & 16 deletions 3rdparty/jvm/com/fasterxml/jackson/module/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,6 @@ java_library(
],
)

java_library(
name = "jackson_module_paranamer",
visibility = [
"//3rdparty/jvm:__subpackages__",
],
exports = [
"//external:jar/com/fasterxml/jackson/module/jackson_module_paranamer",
],
runtime_deps = [
"//3rdparty/jvm/com/fasterxml/jackson/core:jackson_databind",
"//3rdparty/jvm/com/thoughtworks/paranamer",
],
)

scala_import(
name = "jackson_module_scala",
jars = [
Expand All @@ -35,11 +21,10 @@ scala_import(
"//visibility:public",
],
runtime_deps = [
":jackson_module_paranamer",
"//3rdparty/jvm/com/fasterxml/jackson/core:jackson_annotations",
"//3rdparty/jvm/com/fasterxml/jackson/core:jackson_core",
"//3rdparty/jvm/com/fasterxml/jackson/core:jackson_databind",
"//3rdparty/jvm/com/thoughtworks/paranamer",
"//3rdparty/jvm/org/scala_lang:scala_library",
"//3rdparty/jvm/org/scala_lang:scala_reflect",
],
)
19 changes: 19 additions & 0 deletions 3rdparty/jvm/net/bytebuddy/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
java_library(
name = "byte_buddy",
visibility = [
"//3rdparty/jvm:__subpackages__",
],
exports = [
"//external:jar/net/bytebuddy/byte_buddy",
],
)

java_library(
name = "byte_buddy_agent",
visibility = [
"//3rdparty/jvm:__subpackages__",
],
exports = [
"//external:jar/net/bytebuddy/byte_buddy_agent",
],
)
2 changes: 1 addition & 1 deletion 3rdparty/jvm/org/hamcrest/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
java_library(
name = "hamcrest_core",
visibility = [
"//visibility:public",
"//3rdparty/jvm:__subpackages__",
],
exports = [
"//external:jar/org/hamcrest/hamcrest_core",
Expand Down
13 changes: 2 additions & 11 deletions 3rdparty/jvm/org/mockito/BUILD
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
java_library(
name = "mockito_all",
visibility = [
"//visibility:public",
],
exports = [
"//external:jar/org/mockito/mockito_all",
],
)

java_library(
name = "mockito_core",
visibility = [
Expand All @@ -17,7 +7,8 @@ java_library(
"//external:jar/org/mockito/mockito_core",
],
runtime_deps = [
"//3rdparty/jvm/org/hamcrest:hamcrest_core",
"//3rdparty/jvm/net/bytebuddy:byte_buddy",
"//3rdparty/jvm/net/bytebuddy:byte_buddy_agent",
"//3rdparty/jvm/org/objenesis",
],
)
66 changes: 31 additions & 35 deletions 3rdparty/workspace.bzl

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ Bazelisk can be installed in different ways, see [here](https://docs.bazel.build
### Test

```
bazel test //...:all
bazel test //...
```

### Build

```
bazel build //...:all
bazel build //...
```

> Note: In bazel, target spec `//..:all` indicates all rules in all packages beneath workspace, thus `bazel build //...:all` implies build everything.
> Note: In bazel, target spec `//...` indicates all targets in all packages beneath workspace, thus `bazel build //...` implies build everything.
### Intellij

Expand All @@ -50,8 +50,8 @@ If you are using Intellij + Bazel, you can import the project directly with:
* Select "Import project view file" and select the `ij.bazelproject` file
* Select "Finish" with Infer from: Workspace (the default selection)

The newest version of Intellij does not play nicely with Bazel (and its plugins). We recommend using Intellij 2018.3.6
with Bazel plugin version v2019.04.15.0.5
The newest version of Intellij does not play nicely with Bazel (and its plugins). We recommend using the latest version
of Intellij with the latest version of Bazel plugin.

## Python

Expand Down
26 changes: 18 additions & 8 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")
load("//3rdparty:workspace.bzl", "maven_dependencies")

#-- Skylib begin --#
Expand All @@ -13,15 +13,25 @@ load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")

bazel_skylib_workspace()

load("@bazel_skylib//lib:versions.bzl", "versions")
#-- Skylib end --#

versions.check(
# Maximum version is inclusive, so set the maximum minor version to 99.
# This allows us to freely switch between minor versions without touching the WORKSPACE file.
maximum_bazel_version = "5.99.0",
minimum_bazel_version = "5.0.0",
#-- Java start --#
RULES_JAVA_VERSION = "7.3.2"

http_archive(
name = "rules_java",
sha256 = "3121a00588b1581bd7c1f9b550599629e5adcc11ba9c65f482bbd5cfe47fdf30",
urls = [
"https://github.com/bazelbuild/rules_java/releases/download/%s/rules_java-%s.tar.gz" % (RULES_JAVA_VERSION, RULES_JAVA_VERSION),
],
)
#-- Skylib end --#

load("@rules_java//java:repositories.bzl", "rules_java_dependencies", "rules_java_toolchains")

rules_java_dependencies()

rules_java_toolchains()
#-- Java end --#

#-- Maven start --#
maven_dependencies()
Expand Down
22 changes: 8 additions & 14 deletions dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ dependencies:
jackson:
lang: java
modules: [ "annotations", "core", "databind" ]
version: "2.9.5"
version: "2.17.0"

com.fasterxml.jackson.dataformat:
jackson:
lang: java
modules: [ "dataformat-csv", "dataformat-yaml" ]
version: "2.9.5"
version: "2.17.0"

com.fasterxml.jackson.module:
jackson-module-parameter-names:
lang: java
version: "2.9.5"
version: "2.17.0"
jackson-module-scala:
lang: scala
version: "2.9.5"
version: "2.17.0"

com.google.guava:
failureaccess:
Expand Down Expand Up @@ -85,7 +85,7 @@ dependencies:
junit:
junit:
lang: java
version: "4.11"
version: "4.13.2"

log4j:
log4j:
Expand All @@ -95,7 +95,7 @@ dependencies:
org.apache.commons:
commons-lang3:
lang: java
version: "3.7"
version: "3.12.0"

org.apache.kafka:
kafka:
Expand Down Expand Up @@ -123,16 +123,10 @@ dependencies:
lang: java
version: "1.70"

org.hamcrest:
hamcrest-core:
lang: java
version: "1.3"

org.mockito:
mockito:
mockito-core:
lang: java
modules: [ "all", "core" ]
version: "1.10.19"
version: "4.11.0"

org.scala-lang:
scala-library:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,17 @@
package com.tesla.data.acl;

import static java.util.Collections.emptyList;
import static org.mockito.Matchers.anyCollectionOf;
import static org.mockito.ArgumentMatchers.anyCollection;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

import org.apache.kafka.common.acl.AclBinding;
import org.apache.kafka.common.acl.AclBindingFilter;
import org.junit.Before;
import org.junit.Test;

import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;

public class AclEnforcerTest {
Expand All @@ -36,13 +34,12 @@ public void setup() throws IOException {
@Test
public void testCreateDryRun() throws IOException {
enforcer.create(acls);
verify(aclService, times(0)).create(anyCollectionOf(AclBinding.class));
verify(aclService, times(0)).create(anyCollection());
}

@Test
public void testDeleteDryRun() throws IOException {
enforcer.delete(acls);
verify(aclService, times(0)).delete(anyCollectionOf(AclBinding.class));
verify(aclService, times(0)).delete(anyCollection());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ java_test(
deps = [
"//3rdparty/jvm/junit",
"//3rdparty/jvm/org/apache/kafka:kafka_clients",
"//3rdparty/jvm/org/mockito:mockito_all",
"//3rdparty/jvm/org/mockito:mockito_core",
"//kafka_consumer_freshness_tracker/src/main/java/com/tesla/data/consumer/freshness",
],
)
Expand All @@ -16,8 +16,7 @@ java_test(
"//3rdparty/jvm/com/fasterxml/jackson/core:jackson_databind",
"//3rdparty/jvm/com/squareup/okhttp3:okhttp",
"//3rdparty/jvm/junit",
"//3rdparty/jvm/org/hamcrest:hamcrest_core",
"//3rdparty/jvm/org/mockito:mockito_all",
"//3rdparty/jvm/org/mockito:mockito_core",
"//3rdparty/jvm_shaded/com/google/guava_shaded",
"//kafka_consumer_freshness_tracker/src/main/java/com/tesla/data/consumer/freshness",
],
Expand All @@ -35,7 +34,7 @@ java_test(
"//3rdparty/jvm/io/prometheus:simpleclient",
"//3rdparty/jvm/junit",
"//3rdparty/jvm/org/apache/kafka:kafka_clients",
"//3rdparty/jvm/org/mockito:mockito_all",
"//3rdparty/jvm/org/mockito:mockito_core",
"//3rdparty/jvm_shaded/com/google/guava_shaded",
"//kafka_consumer_freshness_tracker/src/main/java/com/tesla/data/consumer/freshness",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
package com.tesla.data.consumer.freshness;

import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.argThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

Expand All @@ -18,8 +18,6 @@
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
Expand Down Expand Up @@ -137,18 +135,7 @@ public void testGetClusterBootstrapServers() throws Exception {
}

private Request expectPath(String path) {
return argThat(new BaseMatcher<Request>() {
@Override
public void describeTo(Description description) {
description.appendText("Requested URL does not match expected: " + path);
}

@Override
public boolean matches(Object o) {
Request request = (Request) o;
return request.url().encodedPath().equals(path);
}
});
return argThat(request -> request.url().encodedPath().equals(path));
}

private Answer<Call> respondWithJson(Object o) {
Expand Down
Loading

0 comments on commit da8134f

Please sign in to comment.