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
73 changes: 1 addition & 72 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -144,76 +144,8 @@ tasks.register<Exec>("generateTestSourcesNoImports") {
)
}

tasks.register<Exec>("generateCelConformance") {
dependsOn("generateCelConformanceTestTypes", "filterBufGenYaml")
description = "Generates CEL conformance code with buf generate for unit tests."
val template = layout.buildDirectory.file("buf-gen-templates/src/test/resources/proto/buf.gen.cel.yaml")
inputs.files(buf)
inputs.file(template)
inputs.property("celSpecVersion", project.findProperty("cel.spec.version").toString())
outputs.dir(layout.buildDirectory.dir("generated/test-sources/bufgen-cel"))
commandLine(
buf.asPath,
"generate",
"--template",
template.get().asFile.absolutePath,
"buf.build/google/cel-spec:${project.findProperty("cel.spec.version")}",
"--exclude-path",
"cel/expr/conformance/proto2",
"--exclude-path",
"cel/expr/conformance/proto3",
)
}

// The conformance tests use the Protobuf package path for tests that use these types.
// i.e. cel.expr.conformance.proto3.TestAllTypes. But, if we use managed mode it adds 'com'
// to the prefix. Additionally, we can't disable managed mode because the java_package option
// specified in these proto files is "dev.cel.expr.conformance.proto3". So, to get around this,
// we're generating these separately and specifying a java_package override of the package we need.
tasks.register<Exec>("generateCelConformanceTestTypes") {
dependsOn("exportProtovalidateModule", "filterBufGenYaml")
description = "Generates CEL conformance test types with buf generate for unit tests using a Java package override."
val template = layout.buildDirectory.file("buf-gen-templates/src/test/resources/proto/buf.gen.cel.testtypes.yaml")
inputs.files(buf)
inputs.file(template)
inputs.property("celSpecVersion", project.findProperty("cel.spec.version").toString())
outputs.dir(layout.buildDirectory.dir("generated/test-sources/bufgen-cel-testtypes"))
commandLine(
buf.asPath,
"generate",
"--template",
template.get().asFile.absolutePath,
"buf.build/google/cel-spec:${project.findProperty("cel.spec.version")}",
"--path",
"cel/expr/conformance/proto3",
)
}

var getCelTestData =
tasks.register<Exec>("getCelTestData") {
val celVersion = project.findProperty("cel.spec.version")
val fileUrl = "https://raw.githubusercontent.com/google/cel-spec/refs/tags/$celVersion/tests/simple/testdata/string_ext.textproto"
val targetDir = File("${project.projectDir}/src/test/resources/testdata")
val file = File(targetDir, "string_ext_$celVersion.textproto")

onlyIf {
// Only run curl if file doesn't exist
!file.exists()
}
doFirst {
file.parentFile.mkdirs()
commandLine(
"curl",
"-fsSL",
"-o",
file.absolutePath,
fileUrl,
)
}
}

tasks.register("generateTestSources") {
dependsOn("generateTestSourcesImports", "generateTestSourcesNoImports", "generateCelConformance")
dependsOn("generateTestSourcesImports", "generateTestSourcesNoImports")
description = "Generates code with buf generate for unit tests"
}

Expand Down Expand Up @@ -309,8 +241,6 @@ sourceSets {
java {
srcDir(layout.buildDirectory.dir("generated/test-sources/bufgen-imports"))
srcDir(layout.buildDirectory.dir("generated/test-sources/bufgen-noimports"))
srcDir(layout.buildDirectory.dir("generated/test-sources/bufgen-cel"))
srcDir(layout.buildDirectory.dir("generated/test-sources/bufgen-cel-testtypes"))
}
}
}
Expand Down Expand Up @@ -351,7 +281,6 @@ allprojects {
}
}
tasks.withType<Test>().configureEach {
dependsOn(getCelTestData)
useJUnitPlatform()
this.testLogging {
events("failed")
Expand Down
3 changes: 0 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,3 @@ protovalidate.conformance.args = --strict_message --strict_error --expected_fail

# Argument to the license-header CLI
license-header.years = 2023-2026

# Version of the cel-spec that this implementation is conformant with
cel.spec.version = v0.24.0
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[versions]
assertj = "3.27.7"
buf = "1.75.0"
cel = "0.14.0"
cel = "0.15.0"
error-prone = "2.51.0"
junit = "5.14.4"
maven-publish = "0.37.0"
Expand Down
10 changes: 0 additions & 10 deletions src/main/java/build/buf/protovalidate/CustomDeclarations.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,6 @@ static List<CelFunctionDecl> create() {
}
decls.add(newFunctionDeclaration("unique", uniqueOverloads));

// Add 'format' function declaration
List<CelOverloadDecl> formatOverloads = new ArrayList<>();
formatOverloads.add(
newMemberOverload(
"format_list_dyn",
SimpleType.STRING,
Arrays.asList(SimpleType.STRING, ListType.create(SimpleType.DYN))));

decls.add(newFunctionDeclaration("format", formatOverloads));

return Collections.unmodifiableList(decls);
}
}
10 changes: 0 additions & 10 deletions src/main/java/build/buf/protovalidate/CustomOverload.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ static List<CelFunctionBinding> create(
bindings.addAll(
Arrays.asList(
celGetField(),
celFormat(),
celStartsWithBytes(),
celEndsWithBytes(),
celContainsBytes(),
Expand Down Expand Up @@ -99,15 +98,6 @@ private static CelFunctionBinding celGetField() {
});
}

/**
* Creates a custom binary function overload for the "format" operation.
*
* @return The {@link CelFunctionBinding} instance for the "format" operation.
*/
private static CelFunctionBinding celFormat() {
return CelFunctionBinding.from("format_list_dyn", String.class, List.class, Format::format);
}

/**
* Creates a custom unary function overload for the "unique" operation.
*
Expand Down
Loading
Loading