Skip to content

Commit

Permalink
Remove AutoValue and JSR 250 embedded into unshaded jar.
Browse files Browse the repository at this point in the history
This CL also adds a test that ensures we don't accidentally pull in non-compiler code into the maven artifact again.

This should address the problem in #4161

PiperOrigin-RevId: 703246074
  • Loading branch information
gkdn authored and copybara-github committed Dec 5, 2024
1 parent 36699d5 commit 4bf1cb0
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ build --define=COMPILER_VERSION=1.0-SNAPSHOT

# Setting for running in remote CI
build --color=yes

test --test_output=errors
37 changes: 36 additions & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,48 @@ genrule(

java_export(
name = "compiler_unshaded",
# Compile time dependencies that are not added as @maven//: need to be excluded.
excluded_workspaces = {
"javax_annotation_jsr250_api": None,
"com_google_auto_value_auto_value_annotations": None,
},
maven_coordinates = "com.google.javascript:closure-compiler-unshaded:{0}".format(version),
pom_template = "maven/closure-compiler-unshaded.pom.xml.tpl",
tags = [
"no-javadocs", # Generated from the compiler_lib_no_runtime_libs.javadoc target.
],
runtime_deps = [
"//:compiler_unshaded_lib",
],
)

# Owned packages. Everything else should be a maven dependency.
ALLOWED_PACKAGES = [
"com.google.javascript", # Compiler code
"com.google.debugging", # Compiler code
"com.google.protobuf.Descriptors", # Generated proto
"com.google.protobuf.MapField", # Generated proto
]

sh_test(
name = "compiler_unshaded_content_test",
srcs = ["check_jar_content.sh"],
args = [
"$(location compiler_unshaded)",
"\\\\|".join(ALLOWED_PACKAGES).replace(".", "/"),
],
data = [":compiler_unshaded"],
)

genrule(
name = "check_jar_content",
outs = ["check_jar_content.sh"],
cmd = """echo '
OUT=$$(jar -tf $$1|grep \\.class|grep -v "$$2");
if [[ -n $$OUT ]]; then echo Unexpected: $$OUT && exit 1; fi
' > $@""",
)

java_library(
name = "compiler_unshaded_lib",
srcs = [
Expand Down Expand Up @@ -147,9 +182,9 @@ java_library(
java_library(
name = "compiler_lib",
resources = [
":src/java/com/google/javascript/jscomp/js/polyfills.txt",
":runtime_libs_srcs",
":runtime_libs_typedast",
":src/java/com/google/javascript/jscomp/js/polyfills.txt",
],
exports = [":compiler_lib_no_runtime_libs"],
)
Expand Down
1 change: 1 addition & 0 deletions build_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ unset ANDROID_HOME

bazel build :all

bazel test :compiler_unshaded_content_test --test_output=errors
# TODO: Run other tests needed for open source verification

0 comments on commit 4bf1cb0

Please sign in to comment.