Skip to content

Commit 20dd663

Browse files
authored
Introduce cel-standalone (no dependencies) artifact (#479)
Generated Protobuf code must be used with the exact same Protobuf runtime version, because especially provides no back-/forward compatibility guarantees. This change introduces a new artifact `cel-standalone`, which provides a shadow/uber jar with including relocated classes of the required dependencies. `cel-standalone` should only be used when there are library compatibility issues, but must not be used in combination with other CEL artifacts.
1 parent 61cb2b6 commit 20dd663

File tree

6 files changed

+105
-6
lines changed

6 files changed

+105
-6
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,16 @@ dependencies {
201201
}
202202
```
203203

204+
## Dependency-free artifact
205+
206+
The `org.projectnessie.cel:cel-standalone` contains everything from CEL-Java and has no dependencies.
207+
It comes with relocated dependencies.
208+
209+
Using `cel-standalone` is especially useful when your project requires different versions of
210+
`protobuf-java`.
211+
212+
Use _either_ `cel-tools` _or_ `cel-standalone` - never both!
213+
204214
## Motivation to have a CEL-Java port
205215

206216
The [Common Expression Language](https://github.com/google/cel-spec/) allows simple computations

bom/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ dependencies {
2929
api(project(":cel-conformance"))
3030
api(project(":cel-jackson"))
3131
api(project(":cel-tools"))
32+
api(project(":cel-standalone"))
3233
}
3334
}
3435

gradle/libs.versions.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ idea-ext = { module = "gradle.plugin.org.jetbrains.gradle.plugin.idea-ext:gradle
4848
immutables-value-annotations = { module = "org.immutables:value-annotations", version.ref = "immutables" }
4949
immutables-value-processor = { module = "org.immutables:value-processor", version.ref = "immutables" }
5050
jackson-bom = { module = "com.fasterxml.jackson:jackson-bom", version = "2.16.0" }
51-
jackson-core = { module = "com.fasterxml.jackson.core:jackson-databind" }
52-
jackson-dataformat-protobuf = { module = "com.fasterxml.jackson.dataformat:jackson-dataformat-protobuf" }
53-
jackson-dataformat-yaml = { module = "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml" }
5451
jacoco-maven-plugin = { module = "org.jacoco:jacoco-maven-plugin", version.ref = "jacoco" }
5552
jandex-plugin = { module = "com.github.vlsi.gradle:jandex-plugin", version.ref = "jandexPlugin" }
5653
jmh-core = { module = "org.openjdk.jmh:jmh-core", version.ref = "jmh" }

jackson/build.gradle.kts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ dependencies {
2828
api(project(":cel-core"))
2929

3030
implementation(platform(libs.jackson.bom))
31-
implementation(libs.jackson.core)
32-
implementation(libs.jackson.dataformat.protobuf)
33-
implementation(libs.jackson.dataformat.yaml)
31+
implementation("com.fasterxml.jackson.core:jackson-databind")
32+
implementation("com.fasterxml.jackson.core:jackson-core")
33+
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-protobuf")
34+
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml")
3435

3536
testImplementation(project(":cel-tools"))
3637
testAnnotationProcessor(libs.immutables.value.processor)

settings.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ gradle.beforeProject {
7575
"core" -> "Common-Expression-Language - Java - Core Module"
7676
"tools" -> "Common-Expression-Language - Script Tools"
7777
"jackson" -> "Common-Expression-Language - Jackson Type Registry"
78+
"standalone" -> "Common-Expression-Language - CEL with relocated protobuf-java"
7879
else -> name
7980
}
8081
}
@@ -96,4 +97,6 @@ celProject("conformance")
9697

9798
celProject("tools")
9899

100+
celProject("standalone")
101+
99102
celProject("bom")

standalone/build.gradle.kts

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
* Copyright (C) 2023 The Authors of CEL-Java
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+
* http://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+
17+
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
18+
19+
plugins {
20+
`java-library`
21+
`maven-publish`
22+
signing
23+
id("com.github.johnrengelman.shadow")
24+
`cel-conventions`
25+
}
26+
27+
dependencies {
28+
api(project(":cel-tools"))
29+
api(project(":cel-jackson"))
30+
api(project(":cel-generated-antlr", configuration = "shadow"))
31+
32+
compileOnly(libs.protobuf.java)
33+
compileOnly(libs.agrona)
34+
35+
compileOnly(platform(libs.jackson.bom))
36+
compileOnly("com.fasterxml.jackson.core:jackson-databind")
37+
compileOnly("com.fasterxml.jackson.core:jackson-core")
38+
compileOnly("com.fasterxml.jackson.dataformat:jackson-dataformat-protobuf")
39+
compileOnly("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml")
40+
}
41+
42+
val shadowJar = tasks.named<ShadowJar>("shadowJar")
43+
44+
shadowJar.configure {
45+
relocate("com.google.protobuf", "org.projectnessie.cel.relocated.protobuf")
46+
relocate("com.fasterxml.jackson", "org.projectnessie.cel.relocated.jackson")
47+
relocate("org.agrona", "org.projectnessie.cel.relocated.agrona")
48+
manifest {
49+
attributes["Specification-Title"] = "Common-Expression-Language - dependency-free CEL"
50+
attributes["Specification-Version"] = libs.protobuf.java.get().version
51+
}
52+
configurations = listOf(project.configurations.getByName("compileClasspath"))
53+
dependencies {
54+
include(project(":cel-tools"))
55+
include(project(":cel-core"))
56+
include(project(":cel-jackson"))
57+
include(project(":cel-generated-pb"))
58+
include(project(":cel-generated-antlr"))
59+
60+
include(dependency(libs.protobuf.java.get()))
61+
include(dependency("com.fasterxml.jackson.core:jackson-databind"))
62+
include(dependency("com.fasterxml.jackson.core:jackson-core"))
63+
include(dependency("com.fasterxml.jackson.core:jackson-annotations"))
64+
include(dependency("com.fasterxml.jackson.dataformat:jackson-dataformat-protobuf"))
65+
include(dependency("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml"))
66+
include(dependency(libs.agrona.get()))
67+
}
68+
}
69+
70+
tasks.named("compileJava").configure { finalizedBy(shadowJar) }
71+
72+
tasks.named("processResources").configure { finalizedBy(shadowJar) }
73+
74+
tasks.named("jar").configure { dependsOn("processJandexIndex", "shadowJar") }
75+
76+
shadowJar.configure {
77+
outputs.cacheIf { false } // do not cache uber/shaded jars
78+
archiveClassifier.set("")
79+
mergeServiceFiles()
80+
}
81+
82+
tasks.named<Jar>("jar").configure {
83+
dependsOn(shadowJar)
84+
archiveClassifier.set("raw")
85+
}
86+
87+
tasks.withType<ShadowJar>().configureEach { exclude("META-INF/jandex.idx") }

0 commit comments

Comments
 (0)