Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 27 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ The CEL specification can be found [here](https://github.com/google/cel-spec).

## Getting started

The easiest way to get started is to add the CEL-Java BOM and `cel-tools` to your project.
The easiest way to get started is to add the CEL-Java BOM, `cel-tools`, and one generated protobuf
artifact to your project.

Maven:

Expand All @@ -47,6 +48,10 @@ Maven:
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.projectnessie.cel</groupId>
<artifactId>cel-generated-pb</artifactId>
</dependency>
<dependency>
<groupId>org.projectnessie.cel</groupId>
<artifactId>cel-tools</artifactId>
Expand All @@ -59,12 +64,22 @@ Gradle:
```groovy
dependencies {
implementation(enforcedPlatform("org.projectnessie.cel:cel-bom:0.6.2"))
implementation("org.projectnessie.cel:cel-generated-pb")
implementation("org.projectnessie.cel:cel-tools")
}
```

The `cel-bom` artifact is available for CEL-Java version 0.3.0 and newer.

Starting with CEL-Java 0.7.0, `cel-core`, `cel-tools`, and the Jackson integration artifacts no
longer choose a generated protobuf runtime transitively. Add exactly one of these artifacts:

- `org.projectnessie.cel:cel-generated-pb`
- `org.projectnessie.cel:cel-generated-pb3`

Do not put both generated protobuf artifacts on the same classpath; they provide the same generated
CEL protobuf classes for different protobuf runtime choices.

## Usage

### Basic scripts
Expand Down Expand Up @@ -102,7 +117,8 @@ public class MyClass {

### Protobuf objects

Protobuf objects and schemas are supported out of the box via `com.google.protobuf:protobuf-java`.
Protobuf objects and schemas are supported through the generated protobuf artifact selected in your
dependencies, either `cel-generated-pb` or `cel-generated-pb3`.

```protobuf
syntax = "proto3";
Expand Down Expand Up @@ -182,6 +198,7 @@ To use Jackson 3, add `cel-jackson3` in addition to `cel-tools` or `cel-core`:
```groovy
dependencies {
implementation(enforcedPlatform("org.projectnessie.cel:cel-bom:0.6.2"))
implementation("org.projectnessie.cel:cel-generated-pb")
implementation("org.projectnessie.cel:cel-tools")
implementation("org.projectnessie.cel:cel-jackson3")
}
Expand Down Expand Up @@ -283,22 +300,24 @@ currently expose a no-standard-library construction option.

| Need | Use |
| --- | --- |
| Normal embedding with `ScriptHost` | `cel-tools` |
| Normal embedding with `ScriptHost` | `cel-tools` plus exactly one of `cel-generated-pb` or `cel-generated-pb3` |
| Dependency isolation / relocated protobuf dependencies | `cel-standalone` |
| Jackson 3 object access | `cel-tools` or `cel-core` plus `cel-jackson3` |
| Jackson 2 object access | `cel-tools` or `cel-core` plus `cel-jackson` |
| Jackson 3 object access | `cel-tools` or `cel-core` plus `cel-jackson3` and one generated protobuf artifact |
| Jackson 2 object access | `cel-tools` or `cel-core` plus `cel-jackson` and one generated protobuf artifact |

Use either `cel-tools` or `cel-standalone`, never both.

### Dependency-free artifact

The `org.projectnessie.cel:cel-standalone` artifact contains everything from CEL-Java and has no
dependencies. It comes with relocated protobuf dependencies.
The `org.projectnessie.cel:cel-standalone` artifact contains CEL-Java's core runtime and relocated
protobuf dependencies in one dependency-isolated artifact.

Using `cel-standalone` is especially useful when your project requires different versions of
`protobuf-java`.

If you need CEL-Java's Jackson functionality, include the Jackson dependencies in your project.
Jackson runtimes are intentionally not relocated into `cel-standalone`. If you need CEL-Java's
Jackson functionality, choose the Jackson version you want and include those Jackson dependencies in
your project.

## Implementation notes

Expand Down
1 change: 1 addition & 0 deletions build-tool-integ-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ repositories {

dependencies {
implementation(enforcedPlatform("org.projectnessie.cel:cel-bom:${System.getProperty("cel.version")}"))
implementation("org.projectnessie.cel:${System.getProperty("cel.generated.pb.artifact", "cel-generated-pb")}")
implementation("org.projectnessie.cel:cel-tools")
implementation("org.projectnessie.cel:cel-jackson")
}
5 changes: 5 additions & 0 deletions build-tool-integ-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>8</maven.compiler.release>
<cel.version>0.6.2</cel.version>
<cel.generated.pb.artifact>cel-generated-pb</cel.generated.pb.artifact>
</properties>

<dependencyManagement>
Expand All @@ -42,6 +43,10 @@
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.projectnessie.cel</groupId>
<artifactId>${cel.generated.pb.artifact}</artifactId>
</dependency>
<dependency>
<groupId>org.projectnessie.cel</groupId>
<artifactId>cel-tools</artifactId>
Expand Down
47 changes: 41 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

import org.gradle.api.tasks.TaskProvider
import org.jetbrains.gradle.ext.settings
import org.jetbrains.gradle.ext.taskTriggers

Expand All @@ -27,34 +28,68 @@ mapOf("versionJacoco" to libs.versions.jacoco.get(), "versionJandex" to libs.ver

tasks.named<Wrapper>("wrapper") { distributionType = Wrapper.DistributionType.ALL }

val buildToolIntegrationGradle =
tasks.register<Exec>("buildToolIntegrationGradle") {
fun registerBuildToolIntegrationGradleTask(
taskName: String,
generatedProtobufArtifact: String,
): TaskProvider<Exec> =
tasks.register<Exec>(taskName) {
group = "Verification"
description =
"Checks whether bom works fine with Gradle, requires preceding publishToMavenLocal in a separate Gradle invocation"

workingDir = file("build-tool-integ-tests")
commandLine("./gradlew", "jar", "-Dcel.version=${project.version}")
commandLine(
"./gradlew",
"jar",
"-Dcel.version=${project.version}",
"-Dcel.generated.pb.artifact=$generatedProtobufArtifact",
)
}

val buildToolIntegrationMaven =
tasks.register<Exec>("buildToolIntegrationMaven") {
fun registerBuildToolIntegrationMavenTask(
taskName: String,
generatedProtobufArtifact: String,
): TaskProvider<Exec> =
tasks.register<Exec>(taskName) {
group = "Verification"
description =
"Checks whether bom works fine with Maven, requires preceding publishToMavenLocal in a separate Gradle invocation"

workingDir = file("build-tool-integ-tests")
commandLine("./mvnw", "clean", "package", "-Dcel.version=${project.version}")
commandLine(
"./mvnw",
"clean",
"package",
"-Dcel.version=${project.version}",
"-Dcel.generated.pb.artifact=$generatedProtobufArtifact",
)
}

val buildToolIntegrationGradle =
registerBuildToolIntegrationGradleTask("buildToolIntegrationGradle", "cel-generated-pb")
val buildToolIntegrationGradlePb3 =
registerBuildToolIntegrationGradleTask("buildToolIntegrationGradlePb3", "cel-generated-pb3")
val buildToolIntegrationMaven =
registerBuildToolIntegrationMavenTask("buildToolIntegrationMaven", "cel-generated-pb")
val buildToolIntegrationMavenPb3 =
registerBuildToolIntegrationMavenTask("buildToolIntegrationMavenPb3", "cel-generated-pb3")

buildToolIntegrationGradlePb3.configure { mustRunAfter(buildToolIntegrationGradle) }

buildToolIntegrationMaven.configure { mustRunAfter(buildToolIntegrationGradlePb3) }

buildToolIntegrationMavenPb3.configure { mustRunAfter(buildToolIntegrationMaven) }

val buildToolIntegrations =
tasks.register("buildToolIntegrations") {
group = "Verification"
description =
"Checks whether bom works fine with build tools, requires preceding publishToMavenLocal in a separate Gradle invocation"

dependsOn(buildToolIntegrationGradle)
dependsOn(buildToolIntegrationGradlePb3)
dependsOn(buildToolIntegrationMaven)
dependsOn(buildToolIntegrationMavenPb3)
}

publishingHelper {
Expand Down
1 change: 1 addition & 0 deletions conformance/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ configurations.all { exclude(group = "org.projectnessie.cel", module = "cel-gene

dependencies {
implementation(project(":cel-core"))
implementation(project(":cel-generated-pb3"))
implementation(testFixtures(project(":cel-core")))
implementation(testFixtures(project(":cel-generated-pb3")))

Expand Down
3 changes: 2 additions & 1 deletion core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ configurations.named("jmhImplementation") { extendsFrom(configurations.testFixtu

dependencies {
implementation(project(":cel-generated-antlr"))
api(project(":cel-generated-pb"))
compileOnly(project(":cel-generated-pb"))

implementation(libs.agrona)

testImplementation(project(":cel-generated-pb"))
testFixturesApi(platform(libs.junit.bom))
testFixturesApi(libs.bundles.junit.testing)
testFixturesApi(libs.protobuf.java)
Expand Down
2 changes: 2 additions & 0 deletions jackson/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ description = "CEL Jackson 2 support"

dependencies {
api(project(":cel-core"))
compileOnly(project(":cel-generated-pb"))

implementation(platform(libs.jackson2.bom))
implementation("com.fasterxml.jackson.core:jackson-databind")
Expand All @@ -33,6 +34,7 @@ dependencies {
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml")

testImplementation(project(":cel-tools"))
testImplementation(project(":cel-generated-pb"))
testAnnotationProcessor(libs.immutables.value.processor)
testCompileOnly(libs.immutables.value.annotations)
testImplementation(libs.findbugs.jsr305)
Expand Down
2 changes: 2 additions & 0 deletions jackson3/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ description = "CEL Jackson 3 support"

dependencies {
api(project(":cel-core"))
compileOnly(project(":cel-generated-pb"))

implementation(platform(libs.jackson3.bom))
implementation("tools.jackson.core:jackson-databind")
Expand All @@ -33,6 +34,7 @@ dependencies {
implementation("tools.jackson.dataformat:jackson-dataformat-yaml")

testImplementation(project(":cel-tools"))
testImplementation(project(":cel-generated-pb"))
testAnnotationProcessor(libs.immutables.value.processor)
testCompileOnly(libs.immutables.value.annotations)
testImplementation(libs.findbugs.jsr305)
Expand Down
30 changes: 18 additions & 12 deletions standalone/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,31 @@ plugins {
id("cel-conventions")
}

val standaloneShadow =
configurations.create("standaloneShadow") {
isCanBeConsumed = false
isCanBeResolved = true
isTransitive = false
}

dependencies {
api(project(":cel-tools"))
api(project(":cel-jackson"))
api(project(":cel-jackson3"))
api(project(":cel-generated-antlr"))

compileOnly(project(":cel-generated-pb"))
compileOnly(libs.protobuf.java)
compileOnly(libs.agrona)

standaloneShadow(project(":cel-core"))
standaloneShadow(project(":cel-tools"))
standaloneShadow(project(":cel-jackson"))
standaloneShadow(project(":cel-jackson3"))
standaloneShadow(project(":cel-generated-antlr"))
standaloneShadow(project(":cel-generated-pb"))
standaloneShadow(libs.protobuf.java)
standaloneShadow(libs.agrona)
}

val shadowJar = tasks.named<ShadowJar>("shadowJar")
Expand All @@ -44,18 +61,7 @@ shadowJar.configure {
attributes["Specification-Title"] = "Common-Expression-Language - dependency-free CEL"
attributes["Specification-Version"] = libs.protobuf.java.get().version
}
configurations = listOf(project.configurations.getByName("runtimeClasspath"))
dependencies {
include(project(":cel-tools"))
include(project(":cel-core"))
include(project(":cel-jackson"))
include(project(":cel-jackson3"))
include(project(":cel-generated-pb"))
include(project(":cel-generated-antlr"))

include(dependency(libs.protobuf.java.get()))
include(dependency(libs.agrona.get()))
}
configurations = listOf(standaloneShadow)
}

tasks.named("compileJava").configure { finalizedBy(shadowJar) }
Expand Down
2 changes: 2 additions & 0 deletions tools/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ apply<ProtobufPlugin>()

dependencies {
api(project(":cel-core"))
compileOnly(project(":cel-generated-pb"))

testImplementation(project(":cel-generated-pb"))
testImplementation(platform(libs.junit.bom))
testImplementation(libs.bundles.junit.testing)
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
Expand Down
Loading