Skip to content

Commit 4bf1cb0

Browse files
gkdncopybara-github
authored andcommitted
Remove AutoValue and JSR 250 embedded into unshaded jar.
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
1 parent 36699d5 commit 4bf1cb0

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

.bazelrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ build --define=COMPILER_VERSION=1.0-SNAPSHOT
1313

1414
# Setting for running in remote CI
1515
build --color=yes
16+
17+
test --test_output=errors

BUILD.bazel

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,48 @@ genrule(
106106

107107
java_export(
108108
name = "compiler_unshaded",
109+
# Compile time dependencies that are not added as @maven//: need to be excluded.
110+
excluded_workspaces = {
111+
"javax_annotation_jsr250_api": None,
112+
"com_google_auto_value_auto_value_annotations": None,
113+
},
109114
maven_coordinates = "com.google.javascript:closure-compiler-unshaded:{0}".format(version),
110115
pom_template = "maven/closure-compiler-unshaded.pom.xml.tpl",
116+
tags = [
117+
"no-javadocs", # Generated from the compiler_lib_no_runtime_libs.javadoc target.
118+
],
111119
runtime_deps = [
112120
"//:compiler_unshaded_lib",
113121
],
114122
)
115123

124+
# Owned packages. Everything else should be a maven dependency.
125+
ALLOWED_PACKAGES = [
126+
"com.google.javascript", # Compiler code
127+
"com.google.debugging", # Compiler code
128+
"com.google.protobuf.Descriptors", # Generated proto
129+
"com.google.protobuf.MapField", # Generated proto
130+
]
131+
132+
sh_test(
133+
name = "compiler_unshaded_content_test",
134+
srcs = ["check_jar_content.sh"],
135+
args = [
136+
"$(location compiler_unshaded)",
137+
"\\\\|".join(ALLOWED_PACKAGES).replace(".", "/"),
138+
],
139+
data = [":compiler_unshaded"],
140+
)
141+
142+
genrule(
143+
name = "check_jar_content",
144+
outs = ["check_jar_content.sh"],
145+
cmd = """echo '
146+
OUT=$$(jar -tf $$1|grep \\.class|grep -v "$$2");
147+
if [[ -n $$OUT ]]; then echo Unexpected: $$OUT && exit 1; fi
148+
' > $@""",
149+
)
150+
116151
java_library(
117152
name = "compiler_unshaded_lib",
118153
srcs = [
@@ -147,9 +182,9 @@ java_library(
147182
java_library(
148183
name = "compiler_lib",
149184
resources = [
150-
":src/java/com/google/javascript/jscomp/js/polyfills.txt",
151185
":runtime_libs_srcs",
152186
":runtime_libs_typedast",
187+
":src/java/com/google/javascript/jscomp/js/polyfills.txt",
153188
],
154189
exports = [":compiler_lib_no_runtime_libs"],
155190
)

build_test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ unset ANDROID_HOME
2222

2323
bazel build :all
2424

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

0 commit comments

Comments
 (0)