Skip to content

Commit b2d808c

Browse files
l46kokcopybara-github
authored andcommitted
Properly establish cross dependenies across maven artifacts
Also removes antlr dependency from `dev.cel:runtime` artifact Fixes: #566 See also grpc/grpc-java#12640 PiperOrigin-RevId: 871541021
1 parent 8e5040d commit b2d808c

File tree

16 files changed

+317
-54
lines changed

16 files changed

+317
-54
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#!/bin/bash
2+
# Copyright 2026 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# https://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
set -o pipefail
17+
18+
TARGETS=(
19+
"//publish:cel"
20+
"//publish:cel_common"
21+
"//publish:cel_compiler"
22+
"//publish:cel_runtime"
23+
"//publish:cel_protobuf"
24+
"//publish:cel_v1alpha1"
25+
)
26+
27+
echo "------------------------------------------------"
28+
echo "Checking for duplicates..."
29+
echo "------------------------------------------------"
30+
31+
JDK8_FLAGS="--java_language_version=8 --java_runtime_version=8"
32+
bazel build $JDK8_FLAGS "${TARGETS[@]}" || { echo "Bazel build failed"; exit 1; }
33+
34+
(
35+
for target in "${TARGETS[@]}"; do
36+
# Locate the jar
37+
jar_path=$(bazel cquery "$target" --output=files 2>/dev/null | grep '\-project.jar$')
38+
39+
if [[ -z "$jar_path" ]]; then
40+
echo "Error: Could not find -project.jar for target $target" >&2
41+
exit 1
42+
fi
43+
44+
# Fix relative paths if running from a subdir.
45+
if [[ ! -f "$jar_path" ]]; then
46+
if [[ -f "../../$jar_path" ]]; then
47+
jar_path="../../$jar_path"
48+
else
49+
echo "Error: File not found at $jar_path" >&2
50+
exit 1
51+
fi
52+
fi
53+
54+
echo "Inspecting: $target" >&2
55+
56+
# Extract classes and append the target name to the end of the line
57+
# Format: dev/cel/expr/Expr.class //publish:cel_compiler
58+
jar tf "$jar_path" | grep "\.class$" | awk -v tgt="$target" '{print $0, tgt}'
59+
done
60+
) | awk '
61+
# $1 is the Class Name, $2 is the Target Name
62+
seen[$1] {
63+
print "❌ DUPLICATE FOUND: " $1
64+
print " Present in: " seen[$1]
65+
print " And in: " $2
66+
dupe=1
67+
next
68+
}
69+
{ seen[$1] = $2 }
70+
71+
END { if (dupe) exit 2 }
72+
'
73+
74+
EXIT_CODE=$?
75+
76+
if [ $EXIT_CODE -eq 0 ]; then
77+
echo "✅ Success: No duplicate classes found."
78+
elif [ $EXIT_CODE -eq 2 ]; then
79+
echo "⛔ Failure: Duplicate classes detected."
80+
else
81+
echo "💥 Error: An unexpected error occurred (e.g., missing jar files). Exit Code: $EXIT_CODE"
82+
fi
83+
84+
exit $EXIT_CODE
85+

.github/workflows/unwanted_deps.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,14 @@ checkUnwantedDeps '//publish:cel_runtime' '@cel_spec'
3636
checkUnwantedDeps '//publish:cel_runtime' 'protobuf_java_util'
3737
checkUnwantedDeps '//publish:cel' 'protobuf_java_util'
3838

39+
# cel_runtime shouldn't depend on antlr
40+
checkUnwantedDeps '//publish:cel_runtime' '@maven//:org_antlr_antlr4_runtime'
41+
3942
# cel_runtime shouldn't depend on the protobuf_lite runtime
4043
checkUnwantedDeps '//publish:cel_runtime' '@maven_android//:com_google_protobuf_protobuf_javalite'
4144
checkUnwantedDeps '//publish:cel' '@maven_android//:com_google_protobuf_protobuf_javalite'
4245

43-
# cel_runtime_android shouldn't depend on the full protobuf runtime
46+
# cel_runtime_android shouldn't depend on the full protobuf runtime or antlr
4447
checkUnwantedDeps '//publish:cel_runtime_android' '@maven//:com_google_protobuf_protobuf_java'
48+
checkUnwantedDeps '//publish:cel_runtime_android' '@maven//:org_antlr_antlr4_runtime'
4549
exit 0

.github/workflows/workflow.yml

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,29 @@ concurrency:
1515
cancel-in-progress: true
1616

1717
jobs:
18+
Static-Checks:
19+
runs-on: ubuntu-latest
20+
timeout-minutes: 30
21+
steps:
22+
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
23+
- run: echo "🐧 Job is running on a ${{ runner.os }} server!"
24+
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
25+
- name: Check out repository code
26+
uses: actions/checkout@v6
27+
- name: Setup Bazel
28+
uses: bazel-contrib/setup-bazel@0.18.0
29+
with:
30+
# Avoid downloading Bazel every time.
31+
bazelisk-cache: true
32+
# Store build cache per workflow.
33+
disk-cache: ${{ github.workflow }}
34+
# Share repository cache between workflows.
35+
repository-cache: true
36+
- name: Unwanted Dependencies
37+
run: .github/workflows/unwanted_deps.sh
38+
- name: Cross-artifact Duplicate Classes Check
39+
run: .github/workflows/cross_artifact_dependencies_check.sh
40+
- run: echo "🍏 This job's status is ${{ job.status }}."
1841
Bazel-Tests:
1942
runs-on: ubuntu-latest
2043
timeout-minutes: 30
@@ -25,7 +48,7 @@ jobs:
2548
- name: Check out repository code
2649
uses: actions/checkout@v6
2750
- name: Setup Bazel
28-
uses: bazel-contrib/setup-bazel@0.14.0
51+
uses: bazel-contrib/setup-bazel@0.18.0
2952
with:
3053
# Avoid downloading Bazel every time.
3154
bazelisk-cache: true
@@ -41,13 +64,33 @@ jobs:
4164
# Exclude codelab exercises as they are intentionally made to fail
4265
# Exclude maven conformance tests. They are only executed when there's version change.
4366
run: bazelisk test ... --deleted_packages=//codelab/src/test/codelab --test_output=errors --test_tag_filters=-conformance_maven --build_tag_filters=-conformance_maven
67+
- run: echo "🍏 This job's status is ${{ job.status }}."
4468

45-
# -- Start of Maven Conformance Tests (Ran only when there's version changes) --
46-
- name: Get changed file
69+
# -- Start of Maven Conformance Tests (Ran only when there's version changes) --
70+
Maven-Conformance:
71+
runs-on: ubuntu-latest
72+
timeout-minutes: 30
73+
steps:
74+
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
75+
- run: echo "🐧 Job is running on a ${{ runner.os }} server!"
76+
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
77+
- name: Check out repository code
78+
uses: actions/checkout@v6
79+
- name: Get changed files
4780
id: changed_file
4881
uses: tj-actions/changed-files@v46
4982
with:
5083
files: publish/cel_version.bzl
84+
- name: Setup Bazel
85+
if: steps.changed_file.outputs.any_changed == 'true'
86+
uses: bazel-contrib/setup-bazel@0.18.0
87+
with:
88+
# Avoid downloading Bazel every time.
89+
bazelisk-cache: true
90+
# Store build cache per workflow.
91+
disk-cache: ${{ github.workflow }}
92+
# Share repository cache between workflows.
93+
repository-cache: true
5194
- name: Verify Version Consistency
5295
if: steps.changed_file.outputs.any_changed == 'true'
5396
run: |
@@ -72,8 +115,4 @@ jobs:
72115
- name: Run Conformance Maven Test on Version Change
73116
if: steps.changed_file.outputs.any_changed == 'true'
74117
run: bazelisk test //conformance/src/test/java/dev/cel/conformance:conformance_maven --test_output=errors
75-
# -- End of Maven Conformance Tests --
76-
77-
- name: Unwanted Dependencies
78-
run: .github/workflows/unwanted_deps.sh
79118
- run: echo "🍏 This job's status is ${{ job.status }}."

common/BUILD.bazel

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ cel_android_library(
7979
exports = ["//common/src/main/java/dev/cel/common:cel_source_android"],
8080
)
8181

82+
java_library(
83+
name = "cel_source_helper",
84+
visibility = ["//:internal"],
85+
exports = ["//common/src/main/java/dev/cel/common:cel_source_helper"],
86+
)
87+
8288
java_library(
8389
name = "cel_ast",
8490
exports = ["//common/src/main/java/dev/cel/common:cel_ast"],
@@ -108,9 +114,6 @@ java_library(
108114
visibility = [
109115
"//:internal",
110116
# TODO: Remove references to the following clients
111-
"//java/com/google/abuse/admin/notebook/compiler/checkedtypes:__pkg__",
112-
"//java/com/google/paymentfraud/v2/util/featurereplay/common/risklogrecordio:__pkg__",
113-
"//java/com/google/payments/consumer/growth/treatmentconfig/management/backend/service/config/utils:__pkg__",
114117
],
115118
exports = ["//common/src/main/java/dev/cel/common:cel_descriptor_util"],
116119
)

common/internal/BUILD.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ java_library(
1111
exports = ["//common/src/main/java/dev/cel/common/internal"],
1212
)
1313

14+
java_library(
15+
name = "code_point_stream",
16+
exports = ["//common/src/main/java/dev/cel/common/internal:code_point_stream"],
17+
)
18+
1419
java_library(
1520
name = "comparison_functions",
1621
exports = ["//common/src/main/java/dev/cel/common/internal:comparison_functions"],

common/src/main/java/dev/cel/common/BUILD.bazel

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ COMPILER_COMMON_SOURCES = [
2121

2222
# keep sorted
2323
SOURCE_SOURCES = [
24-
"CelSourceHelper.java",
2524
"Source.java",
2625
]
2726

@@ -234,6 +233,7 @@ java_library(
234233
tags = [
235234
],
236235
deps = [
236+
":cel_source_helper",
237237
":source",
238238
":source_location",
239239
"//:auto_value",
@@ -250,6 +250,7 @@ cel_android_library(
250250
tags = [
251251
],
252252
deps = [
253+
":cel_source_helper_android",
253254
":source_android",
254255
":source_location_android",
255256
"//:auto_value",
@@ -260,6 +261,30 @@ cel_android_library(
260261
],
261262
)
262263

264+
java_library(
265+
name = "cel_source_helper",
266+
srcs = ["CelSourceHelper.java"],
267+
tags = [
268+
],
269+
deps = [
270+
":source_location",
271+
"//common/annotations",
272+
"//common/internal",
273+
"@maven//:com_google_guava_guava",
274+
],
275+
)
276+
277+
cel_android_library(
278+
name = "cel_source_helper_android",
279+
srcs = ["CelSourceHelper.java"],
280+
deps = [
281+
":source_location_android",
282+
"//common/annotations",
283+
"//common/internal:internal_android",
284+
"@maven_android//:com_google_guava_guava",
285+
],
286+
)
287+
263288
java_library(
264289
name = "cel_ast",
265290
srcs = ["CelAbstractSyntaxTree.java"],
@@ -300,7 +325,6 @@ java_library(
300325
tags = [
301326
],
302327
deps = [
303-
":source_location",
304328
"//common/annotations",
305329
"//common/internal",
306330
"@maven//:com_google_guava_guava",
@@ -312,7 +336,6 @@ cel_android_library(
312336
srcs = SOURCE_SOURCES,
313337
visibility = ["//visibility:private"],
314338
deps = [
315-
":source_location_android",
316339
"//common/annotations",
317340
"//common/internal:internal_android",
318341
"@maven_android//:com_google_guava_guava",

common/src/main/java/dev/cel/common/formats/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ java_library(
7171
],
7272
deps = [
7373
"//:auto_value",
74+
"//common:cel_source_helper",
7475
"//common:source",
7576
"//common:source_location",
7677
"//common/internal",

common/src/main/java/dev/cel/common/internal/BUILD.bazel

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ package(
77
],
88
default_visibility = [
99
"//common/internal:__pkg__",
10+
"//publish:__pkg__",
1011
],
1112
)
1213

1314
# keep sorted
1415
INTERNAL_SOURCES = [
1516
"BasicCodePointArray.java",
1617
"CelCodePointArray.java",
17-
"CodePointStream.java",
1818
"Constants.java",
1919
"EmptyCodePointArray.java",
2020
"Latin1CodePointArray.java",
@@ -34,6 +34,19 @@ CEL_DESCRIPTOR_POOL_SOURCES = [
3434
"DefaultDescriptorPool.java",
3535
]
3636

37+
java_library(
38+
name = "code_point_stream",
39+
srcs = ["CodePointStream.java"],
40+
tags = [
41+
],
42+
deps = [
43+
":internal",
44+
"//common/annotations",
45+
"@maven//:com_google_guava_guava",
46+
"@maven//:org_antlr_antlr4_runtime",
47+
],
48+
)
49+
3750
java_library(
3851
name = "internal",
3952
srcs = INTERNAL_SOURCES,
@@ -48,7 +61,6 @@ java_library(
4861
"@maven//:com_google_errorprone_error_prone_annotations",
4962
"@maven//:com_google_guava_guava",
5063
"@maven//:com_google_protobuf_protobuf_java",
51-
"@maven//:org_antlr_antlr4_runtime",
5264
],
5365
)
5466

@@ -65,7 +77,6 @@ cel_android_library(
6577
"//common/values:values_android",
6678
"@maven//:com_google_errorprone_error_prone_annotations",
6779
"@maven//:com_google_guava_guava",
68-
"@maven//:org_antlr_antlr4_runtime",
6980
"@maven_android//:com_google_guava_guava",
7081
"@maven_android//:com_google_protobuf_protobuf_javalite",
7182
],

common/src/main/java/dev/cel/common/types/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package(
77
],
88
default_visibility = [
99
"//common/types:__pkg__",
10+
"//publish:__pkg__",
1011
],
1112
)
1213

common/src/main/java/dev/cel/common/values/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package(
77
],
88
default_visibility = [
99
"//common/values:__pkg__",
10+
"//publish:__pkg__",
1011
],
1112
)
1213

0 commit comments

Comments
 (0)