Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JacocoRunner script: update for Bazel 6.0+ #1516

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion manual_test/coverage_local_jacocorunner/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ test_coverage_with_local_jacocorunner() {
}

build_local_jacocorunner() {
$root_dir/scripts/build_jacocorunner/build_jacocorunner_bazel_5.0+.sh
# Build for Bazel 6 (as this is the default Bazel version in the repo).
$root_dir/scripts/build_jacocorunner/build_jacocorunner_bazel_5.0+.sh 6
gergelyfabian marked this conversation as resolved.
Show resolved Hide resolved
cp /tmp/bazel_jacocorunner_build/JacocoCoverage_jarjar_deploy.jar $root_dir/manual_test/coverage_local_jacocorunner
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
From 712d62a8238f3a7fe51e1cf4cc2520b5f249e1d3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gergely=20F=C3=A1bi=C3=A1n?= <gergo.fb@gmail.com>
Date: Fri, 18 Dec 2020 11:43:59 +0100
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 8aae1543..067cc6a7 100644
--- a/org.jacoco.build/pom.xml
+++ b/org.jacoco.build/pom.xml
@@ -706,7 +706,7 @@
project.getProperties().setProperty("build.date", buildDate);

buildNumber = project.getProperties().get("buildNumber");
- pkgName = buildNumber.substring(buildNumber.length() - 7, buildNumber.length());
+ pkgName = "43a39aa";
project.getProperties().setProperty("jacoco.runtime.package.name", "org.jacoco.agent.rt.internal_" + pkgName);

void loadLicense(String libraryId) {
--
2.25.1

28 changes: 23 additions & 5 deletions scripts/build_jacocorunner/build_jacocorunner_bazel_5.0+.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,17 @@ build_dir=/tmp/bazel_jacocorunner_build

mkdir -p $build_dir

# Read the Bazel major version.
bazel_major_version=$1
if [ -z "$bazel_major_version" ]; then
echo "Please provide Bazel major version"
exit 1
elif [ "$bazel_major_version" != "5" ] && [ "$bazel_major_version" != "6" ]; then
echo "Unsupported Bazel major version: $bazel_major_version"
exit 1
fi
echo "Selected Bazel major version: $bazel_major_version"

jacoco_repo=$build_dir/jacoco
# Take a fork for Jacoco that contains Scala fixes.
jacoco_remote=https://github.com/gergelyfabian/jacoco
Expand All @@ -83,8 +94,8 @@ jacoco_branch=0.8.7-scala

# Choose the patches that you'd like to use:
jacoco_patches=""
# Bazel needs to have a certain Jacoco package version:
jacoco_patches="$jacoco_patches 0001-Build-Jacoco-for-Bazel-5.0+.patch"
# Bazel needs to have a certain Jacoco package version (dependent on Bazel major version):
jacoco_patches="$jacoco_patches 0001-Build-Jacoco-for-Bazel-$bazel_major_version.0.patch"
# Uncomment this if you are behind a proxy:
#jacoco_patches="$jacoco_patches 0002-Build-Jacoco-behind-proxy.patch"

Expand All @@ -94,9 +105,15 @@ jacoco_version=0.8.7

bazel_repo=$build_dir/bazel
bazel_remote=https://github.com/gergelyfabian/bazel
bazel_version=6.0.0-pre.20220520.1
# Version of Bazel with extending Bazel's Jacoco interface implementation for our 0.8.7-scala jacoco branch.
bazel_branch=jacoco_0.8.7_scala
if [ "$bazel_major_version" = "5" ]; then
bazel_version=6.0.0-pre.20220520.1
# Version of Bazel with extending Bazel's Jacoco interface implementation for our 0.8.7-scala jacoco branch.
bazel_branch=jacoco_0.8.7_scala
else
bazel_version=6.3.2
# Version of Bazel with extending Bazel's Jacoco interface implementation for our 0.8.7-scala jacoco branch.
bazel_branch=6.3.2_jacoco_0.8.7_scala
fi

bazel_build_target=JacocoCoverage_jarjar_deploy.jar

Expand Down Expand Up @@ -132,6 +149,7 @@ mvn clean install
(
cd $bazel_repo
git remote update
git reset --hard HEAD
git checkout $bazel_branch

echo "$bazel_version" > .bazelversion
Expand Down