Skip to content

Commit

Permalink
Remove unnecessary Bazel server jar contents
Browse files Browse the repository at this point in the history
fastutil is very large and thus stripped (but not obfuscated) with proguard.

Also removes some third_party maven deps that are unused.
  • Loading branch information
fmeum committed Jun 18, 2024
1 parent 82e3135 commit 1836a3d
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 41 deletions.
12 changes: 9 additions & 3 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ maven.install(
# keep sorted
"com.beust:jcommander:1.82",
"com.github.ben-manes.caffeine:caffeine:3.0.5",
"com.github.kevinstern:software-and-algorithms:1.0",
"com.github.stephenc.jcip:jcip-annotations:1.0-1",
"com.google.api-client:google-api-client:1.35.2",
"com.google.api-client:google-api-client-gson:1.35.2",
Expand Down Expand Up @@ -162,8 +161,6 @@ maven.install(
"javax.activation:javax.activation-api:1.2.0",
"javax.annotation:javax.annotation-api:1.3.2",
"javax.inject:javax.inject:1",
"net.bytebuddy:byte-buddy:1.14.5",
"net.bytebuddy:byte-buddy-agent:1.14.5",
"org.apache.commons:commons-compress:1.26.1",
"org.apache.commons:commons-pool2:2.8.0",
"org.apache.tomcat:tomcat-annotations-api:8.0.5",
Expand Down Expand Up @@ -349,6 +346,15 @@ http_file(
urls = ["https://github.com/jqlang/jq/releases/download/jq-1.5/jq-win64.exe"],
)

http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "proguard",
build_file = "//third_party/proguard:BUILD",
strip_prefix = "proguard-7.5.0",
urls = ["https://github.com/Guardsquare/proguard/releases/download/v7.5/proguard-7.5.0.tar.gz"],
)

# =========================================
# Other Bazel testing dependencies
# =========================================
Expand Down
12 changes: 3 additions & 9 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion maven_install.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": "THERE_IS_NO_DATA_ONLY_ZUUL",
"__INPUT_ARTIFACTS_HASH": -1365209973,
"__INPUT_ARTIFACTS_HASH": 389666575,
"__RESOLVED_ARTIFACTS_HASH": -554579439,
"conflict_resolution": {
"com.google.code.gson:gson:2.8.9": "com.google.code.gson:gson:2.10.1",
Expand Down
6 changes: 3 additions & 3 deletions src/test/shell/integration/minimal_jdk_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ export BAZEL_SUFFIX="_jdk_minimal"
source "$(rlocation "io_bazel/src/test/shell/integration_test_setup.sh")" \
|| { echo "integration_test_setup.sh not found!" >&2; exit 1; }

# Bazel's install base is < 470MB with minimal JDK and > 480MB with an all
# Bazel's install base is < 385MB with minimal JDK and > 395MB with an all
# modules JDK.
function test_size_less_than_470MB() {
function test_size_less_than_385MB() {
bazel info
ib=$(bazel info install_base)
size=$(du -s "$ib" | cut -d\ -f1)
maxsize=$((1024*470))
maxsize=$((1024*385))
if [ $size -gt $maxsize ]; then
echo "$ib was too big:" 1>&2
du -a "$ib" 1>&2
Expand Down
67 changes: 42 additions & 25 deletions third_party/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ java_plugin(
":apache_velocity",
":auto_common",
":auto_service_lib",
":auto_value_value",
":auto_value_lib",
":guava",
":jsr305",
":tomcat_annotations_api",
Expand All @@ -164,7 +164,7 @@ java_library(
":auto_service_plugin",
],
exports = [
":auto_service_lib",
":auto_service_api",
],
)

Expand All @@ -178,6 +178,13 @@ java_plugin(
],
)

java_library(
name = "auto_service_api",
exports = [
"@maven//:com_google_auto_service_auto_service_annotations",
],
)

java_library(
name = "auto_service_lib",
exports = [
Expand All @@ -194,7 +201,7 @@ java_plugin(
":apache_velocity",
":auto_common",
":auto_service_lib",
":auto_value_value",
":auto_value_lib",
":guava",
":tomcat_annotations_api",
],
Expand All @@ -208,7 +215,7 @@ java_plugin(
":apache_velocity",
":auto_common",
":auto_service_lib",
":auto_value_value",
":auto_value_lib",
":guava",
":tomcat_annotations_api",
],
Expand All @@ -222,7 +229,7 @@ java_plugin(
":apache_velocity",
":auto_common",
":auto_service_lib",
":auto_value_value",
":auto_value_lib",
":guava",
":tomcat_annotations_api",
],
Expand All @@ -247,14 +254,21 @@ java_library(
":auto_value_gson_plugin",
],
exports = [
":auto_value_value",
":auto_value_api",
":tomcat_annotations_api",
"@maven//:com_ryanharter_auto_value_auto_value_gson_runtime",
],
)

java_library(
name = "auto_value_value",
name = "auto_value_api",
exports = [
"@maven//:com_google_auto_value_auto_value_annotations",
],
)

java_library(
name = "auto_value_lib",
exports = [
"@maven//:com_google_auto_value_auto_value",
"@maven//:com_google_auto_value_auto_value_annotations",
Expand All @@ -271,14 +285,6 @@ distrib_jar_filegroup(
enable_distributions = ["debian"],
)

java_library(
name = "byte_buddy",
exports = [
"@maven//:net_bytebuddy_byte_buddy",
"@maven//:net_bytebuddy_byte_buddy_agent",
],
)

alias(
name = "checker_framework_annotations",
actual = "@maven//:org_checkerframework_checker_qual",
Expand All @@ -294,19 +300,30 @@ alias(
actual = "@maven//:com_github_ben_manes_caffeine_caffeine",
)

alias(
# When using new classes from this dependency, make sure to update fastutil.proguard.
java_import(
name = "fastutil",
actual = "@maven//:it_unimi_dsi_fastutil",
jars = [":fastutil_stripped_file"],
)

alias(
name = "hungarian_algorithm",
actual = "@maven//:com_github_kevinstern_software_and_algorithms",
)

alias(
name = "threeten",
actual = "@maven//:org_threeten_threeten_extra",
genrule(
name = "fastutil_stripped_file",
srcs = [
"@maven//:it_unimi_dsi_fastutil_file",
],
outs = ["fastutil-stripped.jar"],
cmd = """
$(location @proguard) \
-injars $< \
-outjars $@ \
-libraryjars '<java.home>/jmods/java.base.jmod(!**.jar;!module-info.class)' \
@$(location fastutil.proguard) \
| tail -n +2 # Skip the "ProGuard, version X" line
""",
tools = [
"fastutil.proguard",
"@proguard",
],
)

java_library(
Expand Down
8 changes: 8 additions & 0 deletions third_party/fastutil.proguard
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-dontobfuscate
-dontoptimize
-keep ,includedescriptorclasses class it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap { *; }
-keep ,includedescriptorclasses class it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap { *; }
-keep ,includedescriptorclasses class it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap { *; }
# Unused, but access `getChannel()` via reflection
-dontnote it.unimi.dsi.fastutil.io.FastBufferedInputStream
-dontnote it.unimi.dsi.fastutil.io.FastBufferedOutputStream
13 changes: 13 additions & 0 deletions third_party/proguard/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
load("@bazel_skylib//rules:native_binary.bzl", "native_binary")

java_binary(
name = "proguard",
main_class = "proguard.ProGuard",
visibility = ["//visibility:public"],
runtime_deps = [":proguard_lib"],
)

java_import(
name = "proguard_lib",
jars = ["lib/proguard.jar"],
)

0 comments on commit 1836a3d

Please sign in to comment.