Skip to content

Commit

Permalink
junit: Do not depend on junit-jupiter-engine
Browse files Browse the repository at this point in the history
The user has to add and control this dependency themselves if they want
to use JUnit 5. Even if we added it, Maven resolution mechanics mean
that we do not control the version anyway.

This fixes an issue introduced by 1ca007d.

See junit-team/junit5#3441 (comment)

Also require fixing an issue in rules_jvm_external that results in
neverlink deps not appearing on the javadoc classpath.
  • Loading branch information
fmeum committed Sep 5, 2023
1 parent c2c9e1f commit 1cd2198
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
3 changes: 3 additions & 0 deletions repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ def jazzer_dependencies(android = False):
# Fixes an incompatibility with latest Bazel introduced in
# https://github.com/bazelbuild/bazel/commit/d0e29582a2e788e8acdaf53fe30ab7f7dc592df3
"//third_party:rules_jvm_external-add-toolchain-to-maven-project-jar.patch",
# https://github.com/bazelbuild/rules_jvm_external/pull/952
# Fixes javadoc generation when using neverlink dependencies.
"//third_party:rules_jvm_external-add-neverlink-deps-to-javadoc-classpath.patch",
],
sha256 = "d31e369b854322ca5098ea12c69d7175ded971435e55c18dd9dd5f29cc5249ac",
strip_prefix = "rules_jvm_external-5.3",
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/code_intelligence/jazzer/junit/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ java_jni_library(
java_library(
name = "junit_internals_compile_only",
neverlink = True,
# Do not add a dependency on junit-jupiter-engine to the POM file. The user
# has to add and control this dependency themselves if they want to use
# JUnit 5. Even if we added it, Maven resolution mechanics mean that we do
# not control the version anyway.
# https://github.com/junit-team/junit5/discussions/3441#discussioncomment-6884855
tags = ["maven:compile-only"],
exports = [
"@maven//:org_junit_jupiter_junit_jupiter_engine",
],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
From 920048a2b213e2c7cb6ce679ffa5a414054339f6 Mon Sep 17 00:00:00 2001
From: Fabian Meumertzheim <[email protected]>
Date: Fri, 1 Sep 2023 22:12:42 +0200
Subject: [PATCH] Add compile-only deps to javadocs classpath

javadoc may have to inspect compile-only dependencies.

Also removes a line that only added elements to a depset that are
already contained in this depset.
---
private/rules/javadoc.bzl | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/private/rules/javadoc.bzl b/private/rules/javadoc.bzl
index 325aced1..3261248a 100644
--- a/private/rules/javadoc.bzl
+++ b/private/rules/javadoc.bzl
@@ -21,9 +21,12 @@ def _javadoc_impl(ctx):

jar_file = ctx.actions.declare_file("%s.jar" % ctx.attr.name)

- # Gather additional files to add to the classpath
- additional_deps = depset(transitive = [dep[JavaInfo].transitive_runtime_jars for dep in ctx.attr.deps])
- classpath = depset(transitive = [dep[JavaInfo].transitive_runtime_jars for dep in ctx.attr.deps] + [additional_deps])
+ # javadoc may need to inspect compile-time dependencies (neverlink)
+ # of the runtime classpath.
+ classpath = depset(
+ transitive = [dep[JavaInfo].transitive_runtime_jars for dep in ctx.attr.deps] +
+ [dep[JavaInfo].transitive_compile_time_jars for dep in ctx.attr.deps],
+ )

# javadoc options and javac options overlap, but we cannot
# necessarily rely on those to derive the javadoc options we need

0 comments on commit 1cd2198

Please sign in to comment.