From 667b9ff66b5779d491780c8d5eac85fffc189566 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gergely=20F=C3=A1bi=C3=A1n?= Date: Wed, 21 Apr 2021 15:50:43 +0200 Subject: [PATCH] JacocoRunner script: update for Bazel 5.0+ Upgraded jacoco package name for Bazel 5.0+. Upgraded jacoco from 0.8.3 to 0.8.6. Jacoco upgrade to 0.8.6 was made in Bazel in: https://github.com/bazelbuild/bazel/issues/11674 https://github.com/bazelbuild/bazel/commit/cb7c1a2ec8de92828a018e2a3450a06f1d1c7efa Removed options for workarounds where those have been fixed in the meantime: Bazel's handling for branch coverage was fixed in: https://github.com/bazelbuild/bazel/issues/12696 --- .../0001-Build-Jacoco-for-Bazel.patch | 14 +++--- .../build_jacocorunner/build_jacocorunner.sh | 49 ++++--------------- 2 files changed, 16 insertions(+), 47 deletions(-) diff --git a/scripts/build_jacocorunner/0001-Build-Jacoco-for-Bazel.patch b/scripts/build_jacocorunner/0001-Build-Jacoco-for-Bazel.patch index a9d7b5d897..94a278d897 100644 --- a/scripts/build_jacocorunner/0001-Build-Jacoco-for-Bazel.patch +++ b/scripts/build_jacocorunner/0001-Build-Jacoco-for-Bazel.patch @@ -1,25 +1,25 @@ -From d4e6b4455e516e3a35058064d32979979cc4f80c Mon Sep 17 00:00:00 2001 +From 712d62a8238f3a7fe51e1cf4cc2520b5f249e1d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gergely=20F=C3=A1bi=C3=A1n?= Date: Fri, 18 Dec 2020 11:43:59 +0100 -Subject: [PATCH 1/2] Build Jacoco for Bazel +Subject: [PATCH] Build Jacoco for Bazel --- org.jacoco.build/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.jacoco.build/pom.xml b/org.jacoco.build/pom.xml -index edb2d126..fcb57f55 100644 +index 8aae1543..067cc6a7 100644 --- a/org.jacoco.build/pom.xml +++ b/org.jacoco.build/pom.xml -@@ -646,7 +646,7 @@ +@@ -706,7 +706,7 @@ project.getProperties().setProperty("build.date", buildDate); buildNumber = project.getProperties().get("buildNumber"); - pkgName = buildNumber.substring(buildNumber.length() - 7, buildNumber.length()); -+ pkgName = "1f1cc91"; ++ pkgName = "b864216"; project.getProperties().setProperty("jacoco.runtime.package.name", "org.jacoco.agent.rt.internal_" + pkgName); - ]]> - + + void loadLicense(String libraryId) { -- 2.25.1 diff --git a/scripts/build_jacocorunner/build_jacocorunner.sh b/scripts/build_jacocorunner/build_jacocorunner.sh index e8475b7b31..24da12881d 100755 --- a/scripts/build_jacocorunner/build_jacocorunner.sh +++ b/scripts/build_jacocorunner/build_jacocorunner.sh @@ -4,39 +4,20 @@ # # The default `JacocoCoverage_jarjar_deploy.jar` has some issues: # -# 1. Bazel uses Jacoco 0.8.3 that has poor Scala support, including a bug that filters out Scala lambdas on Scala >=2.12 -# -# Bug report: -# https://github.com/bazelbuild/rules_scala/issues/1056 -# https://github.com/bazelbuild/bazel/issues/11674 -# -# Backported fix from Jacoco 0.8.5 to Jacoco 0.8.3 (current Bazel is not compatible with Jacoco 0.8.5): -# https://github.com/gergelyfabian/jacoco/tree/0.8.3-scala-lambda-fix -# -# 2. Bazel ignores Jacoco's filtering for branch coverage metrics: -# -# Bug report: -# https://github.com/bazelbuild/bazel/issues/12696 -# -# Proposed fix: -# https://github.com/gergelyfabian/bazel/tree/branch_coverage_respect_jacoco_filtering -# -# 3. Scala support on newer Jacoco versions (including 0.8.5) is still lacking some functionality +# 1. Scala support on newer Jacoco versions (including 0.8.6) is still lacking some functionality # # E.g. a lot of generated methods for case classes, lazy vals or other Scala features are causing falsely missed branches in branch coverage. # # Proposed changes in: # https://github.com/gergelyfabian/jacoco/tree/scala # -# Backported to 0.8.3 (to be usable with current Bazel): -# https://github.com/gergelyfabian/jacoco/tree/0.8.3-scala -# -# These branches also include the Scala 2.12 lambda coverage fix. +# Backported to 0.8.6 (to be usable with current Bazel): +# https://github.com/gergelyfabian/jacoco/tree/0.8.6-scala # # You can use this script to build a custom version of `JacocoCoverage_jarjar_deploy.jar`, including any fixes from the above list you wish # and then provide the built jar as a parameter of `java_toolchain` and/or `scala_toolchain` to use the changed behavior for coverage. # -# Choose the fixes from the above list by configuring the used branches for Bazel and Jacoco repos below. +# Choose the fixes from the above list by configuring the used branch for Jacoco repo below. # # Patches: # @@ -75,11 +56,8 @@ mkdir -p $build_dir jacoco_repo=$build_dir/jacoco # Take a fork for Jacoco that contains Scala fixes. jacoco_remote=https://github.com/gergelyfabian/jacoco -# Choose a branch you'd like to use. -# Default option, take only fixes for Scala 2.12 lambdas backported to Jacoco 0.8.3: -jacoco_branch=0.8.3-scala-lambda-fix -# Advanced option, take further fixes for Scala (2.11, 2.12 and 2.13) - branch in development: -#jacoco_branch=0.8.3-scala +# Take further fixes for Scala (2.11, 2.12 and 2.13) - branch in development: +jacoco_branch=0.8.6-scala # Choose the patches that you'd like to use: jacoco_patches="" @@ -89,18 +67,12 @@ jacoco_patches="$jacoco_patches 0001-Build-Jacoco-for-Bazel.patch" #jacoco_patches="$jacoco_patches 0002-Build-Jacoco-behind-proxy.patch" -# Jacoco version should be 0.8.3 in any case as Bazel is only compatible with that at this moment. -jacoco_version=0.8.3 +# Jacoco version should be 0.8.6 in any case as Bazel is only compatible with that at this moment. +jacoco_version=0.8.6 bazel_repo=$build_dir/bazel bazel_remote=https://github.com/bazelbuild/bazel -bazel_branch=master -bazel_tag=4.1.0 - -# Advanced option: take a fork that has fixes for Jacoco LCOV formatter, to respect Jacoco filtering -# (fixes for Scala in Jacoco respected in Bazel branch coverage): -#bazel_remote=https://github.com/gergelyfabian/bazel -#bazel_branch=branch_coverage_respect_jacoco_filtering +bazel_tag=5.1.1 bazel_build_target=JacocoCoverage_jarjar_deploy.jar @@ -138,9 +110,6 @@ cd $bazel_repo git remote update git checkout tags/$bazel_tag -# Advanced option - check out a branch instead of the release tag -# git checkout origin/$bazel_branch - # Prepare Jacoco version. cd third_party/java/jacoco # Remove any previously unpacked Jacoco files.