Skip to content

Commit da9773c

Browse files
l46kokcopybara-github
authored andcommitted
Release 0.1.0 version
PiperOrigin-RevId: 511248130
1 parent 42e0fd6 commit da9773c

5 files changed

Lines changed: 75 additions & 10 deletions

File tree

README.md

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,12 @@ import dev.cel.common.CelAbstractSyntaxTree;
100100
import dev.cel.runtime.CelRuntimeFactory;
101101

102102
CelRuntime celRuntime = CelRuntimeFactory.standardCelRuntimeBuilder().build();
103-
CelAbstractSyntaxTree ast = CelAbstractSyntaxTree.fromCheckedExpr(checkedExpr);
103+
CelAbstractSyntaxTree ast = CelProtoAbstractSyntaxTree.fromCheckedExpr(checkedExpr);
104104

105105
try {
106-
CelRuntime.Program program=celRuntime.createProgram(ast);
107-
Object evaluatedResult=program.eval(parameterValues);
108-
} catch(CelEvaluationException e) {
106+
CelRuntime.Program program = celRuntime.createProgram(ast);
107+
Object evaluatedResult = program.eval(parameterValues);
108+
} catch (CelEvaluationException e) {
109109
throw new IllegalArgumentException("Evaluation error has occurred.",e);
110110
}
111111
```
@@ -153,7 +153,23 @@ This section will be completed once parser and type-checker has been added.
153153

154154
## Install
155155

156-
CEL-Java will be available in Maven repository soon.
156+
CEL-Java is available in Maven Central Repository. [Download the JARs here][6] or add the following to your build dependencies:
157+
158+
**Maven (pom.xml)**:
159+
160+
```xml
161+
<dependency>
162+
<groupId>dev.cel</groupId>
163+
<artifactId>runtime</artifactId>
164+
<version>0.1.0</version>
165+
</dependency>
166+
```
167+
168+
**Gradle**
169+
170+
```gradle
171+
implementation 'dev.cel:runtime:0.1.0'
172+
```
157173

158174
## Common Questions
159175

@@ -218,4 +234,6 @@ Disclaimer: This is not an official Google product.
218234

219235
[4]: https://github.com/google/cel-go
220236

221-
[5]: https://github.com/google/cel-java/issues
237+
[5]: https://github.com/google/cel-java/issues
238+
239+
[6]: https://search.maven.org/search?q=g:dev.cel

publish/cel_version.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
"""Maven artifact version for CEL."""
15-
CEL_VERSION = "0.1.0-alpha"
15+
CEL_VERSION = "0.1.0"

publish/publish.sh

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,28 @@
11
#!/bin/bash
2+
# Copyright 2022 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+
216
#
317
# Publishes CEL to a Maven repository.
418
#
5-
# To push locally, just run the script
6-
# To publish a SNAPSHOT version, run with -snapshot (-s) flag: "publish.sh --snapshot"
19+
# To push locally, just run the script. On MacOS by default, the artifact lives in ~/.m2/repository
20+
# To publish a SNAPSHOT version, run with -snapshot (-s) flag: "publish.sh --snapshot". Snapshots can be found in https://s01.oss.sonatype.org/#nexus-search;quick~dev.cel
721
# To publish a RELEASE version remotely, run with -release (-r) flag: "publish.sh --release". Note that released maven artifacts are permanent and can never be deleted under any circumstances.
822

9-
# Note: To publish, you must create a pgp certificate and upload it to keyserver.ubuntu.com. See https://blog.sonatype.com/2010/01/how-to-generate-pgp-signatures-with-maven/
23+
# Note, to publish remotely:
24+
# 1. You must create a pgp certificate and upload it to keyserver.ubuntu.com. See https://blog.sonatype.com/2010/01/how-to-generate-pgp-signatures-with-maven/
25+
# 2. You will need to enter the key's password. The prompt appears in GUI, not in terminal. The publish operation will eventually timeout if the password is not entered.
1026

1127
RUNTIME_TARGET=//publish:cel_runtime.publish
1228

runtime/src/test/java/dev/cel/runtime/BUILD.bazel

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ java_library(
1010
"//common/src/main/java/dev/cel/common",
1111
"//common/src/main/java/dev/cel/common:options",
1212
"//common/src/main/java/dev/cel/common:proto_ast",
13+
"//common/src/main/java/dev/cel/common:proto_v1alpha1_ast",
1314
"//common/src/main/java/dev/cel/common/internal:converter",
1415
"//common/src/main/java/dev/cel/common/internal:dynamic_proto",
16+
"//common/src/main/java/dev/cel/common/types:cel_v1alpha1_types",
1517
"//common/src/main/resources/testdata/proto2:messages_extensions_proto2_java_proto",
1618
"//common/src/main/resources/testdata/proto2:messages_proto2_java_proto",
1719
"//common/src/main/resources/testdata/proto3:test_all_types_java_proto",
@@ -20,6 +22,7 @@ java_library(
2022
"//runtime/src/main/java/dev/cel/runtime:runtime_helper",
2123
"//runtime/src/main/java/dev/cel/runtime:unknown_attributes",
2224
"@cel_spec//proto/expr:expr_java_proto",
25+
"@com_google_googleapis//google/api/expr/v1alpha1:expr_java_proto",
2326
"@com_google_googleapis//google/rpc/context:attribute_context_java_proto",
2427
"@com_google_protobuf//:any_proto",
2528
"@com_google_protobuf//:duration_proto",

runtime/src/test/java/dev/cel/runtime/CelRuntimeTest.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,18 @@
1717
import static com.google.common.truth.Truth.assertThat;
1818

1919
import dev.cel.expr.CheckedExpr;
20+
import com.google.api.expr.v1alpha1.Constant;
21+
import com.google.api.expr.v1alpha1.Expr;
22+
import com.google.api.expr.v1alpha1.Type.PrimitiveType;
2023
import com.google.common.collect.ImmutableMap;
2124
import com.google.protobuf.Any;
2225
import com.google.protobuf.ByteString;
2326
import com.google.protobuf.ExtensionRegistry;
2427
import com.google.rpc.context.AttributeContext;
2528
import dev.cel.common.CelOptions;
2629
import dev.cel.common.CelProtoAbstractSyntaxTree;
30+
import dev.cel.common.CelProtoV1Alpha1AbstractSyntaxTree;
31+
import dev.cel.common.types.CelV1AlphaTypes;
2732
import java.util.Base64;
2833
import org.junit.Test;
2934
import org.junit.runner.RunWith;
@@ -74,4 +79,27 @@ public void evaluate_anyPackedEqualityUsingProtoDifferencer_success() throws Exc
7479

7580
assertThat(evaluatedResult).isEqualTo(true);
7681
}
82+
83+
@Test
84+
public void evaluate_v1alpha1CheckedExpr() throws Exception {
85+
// Note: v1alpha1 proto support exists only to help migrate existing consumers.
86+
// New users of CEL should use the canonical protos instead (I.E: dev.cel.expr)
87+
com.google.api.expr.v1alpha1.CheckedExpr checkedExpr =
88+
com.google.api.expr.v1alpha1.CheckedExpr.newBuilder()
89+
.setExpr(
90+
Expr.newBuilder()
91+
.setId(1)
92+
.setConstExpr(Constant.newBuilder().setStringValue("Hello world!").build())
93+
.build())
94+
.putTypeMap(1, CelV1AlphaTypes.create(PrimitiveType.STRING))
95+
.build();
96+
CelRuntime celRuntime = CelRuntimeFactory.standardCelRuntimeBuilder().build();
97+
CelRuntime.Program program =
98+
celRuntime.createProgram(
99+
CelProtoV1Alpha1AbstractSyntaxTree.fromCheckedExpr(checkedExpr).getAst());
100+
101+
String evaluatedResult = (String) program.eval();
102+
103+
assertThat(evaluatedResult).isEqualTo("Hello world!");
104+
}
77105
}

0 commit comments

Comments
 (0)