@@ -72,32 +72,46 @@ tasks.register<Exec>("licenseHeader") {
7272 )
7373}
7474
75+ tasks.register<Copy >(" filterBufGenYaml" ) {
76+ from(" ." )
77+ include(" buf.gen.yaml" , " src/**/buf*gen*.yaml" )
78+ includeEmptyDirs = false
79+ into(layout.buildDirectory.dir(" buf-gen-templates" ))
80+ expand(" protocJavaPluginVersion" to " v${libs.versions.protobuf.get().substringAfter(' .' )} " )
81+ filteringCharset = " UTF-8"
82+ }
83+
7584tasks.register<Exec >(" generateTestSourcesImports" ) {
76- dependsOn(" exportProtovalidateModule" )
85+ dependsOn(" exportProtovalidateModule" , " filterBufGenYaml " )
7786 description = " Generates code with buf generate --include-imports for unit tests."
7887 commandLine(
7988 buf.asPath,
8089 " generate" ,
8190 " --template" ,
82- " src/test/resources/proto/buf.gen.imports.yaml" ,
91+ " ${layout.buildDirectory.get()} /buf-gen-templates/ src/test/resources/proto/buf.gen.imports.yaml" ,
8392 " --include-imports" ,
8493 )
8594}
8695
8796tasks.register<Exec >(" generateTestSourcesNoImports" ) {
88- dependsOn(" exportProtovalidateModule" )
97+ dependsOn(" exportProtovalidateModule" , " filterBufGenYaml " )
8998 description = " Generates code with buf generate --include-imports for unit tests."
90- commandLine(buf.asPath, " generate" , " --template" , " src/test/resources/proto/buf.gen.noimports.yaml" )
99+ commandLine(
100+ buf.asPath,
101+ " generate" ,
102+ " --template" ,
103+ " ${layout.buildDirectory.get()} /buf-gen-templates/src/test/resources/proto/buf.gen.noimports.yaml" ,
104+ )
91105}
92106
93107tasks.register<Exec >(" generateCelConformance" ) {
94- dependsOn(" generateCelConformanceTestTypes" )
108+ dependsOn(" generateCelConformanceTestTypes" , " filterBufGenYaml " )
95109 description = " Generates CEL conformance code with buf generate for unit tests."
96110 commandLine(
97111 buf.asPath,
98112 " generate" ,
99113 " --template" ,
100- " src/test/resources/proto/buf.gen.cel.yaml" ,
114+ " ${layout.buildDirectory.get()} /buf-gen-templates/ src/test/resources/proto/buf.gen.cel.yaml" ,
101115 " buf.build/google/cel-spec:${project.findProperty(" cel.spec.version" )} " ,
102116 " --exclude-path" ,
103117 " cel/expr/conformance/proto2" ,
@@ -112,13 +126,13 @@ tasks.register<Exec>("generateCelConformance") {
112126// specified in these proto files is "dev.cel.expr.conformance.proto3". So, to get around this,
113127// we're generating these separately and specifying a java_package override of the package we need.
114128tasks.register<Exec >(" generateCelConformanceTestTypes" ) {
115- dependsOn(" exportProtovalidateModule" )
129+ dependsOn(" exportProtovalidateModule" , " filterBufGenYaml " )
116130 description = " Generates CEL conformance test types with buf generate for unit tests using a Java package override."
117131 commandLine(
118132 buf.asPath,
119133 " generate" ,
120134 " --template" ,
121- " src/test/resources/proto/buf.gen.cel.testtypes.yaml" ,
135+ " ${layout.buildDirectory.get()} /buf-gen-templates/ src/test/resources/proto/buf.gen.cel.testtypes.yaml" ,
122136 " buf.build/google/cel-spec:${project.findProperty(" cel.spec.version" )} " ,
123137 " --path" ,
124138 " cel/expr/conformance/proto3" ,
@@ -166,9 +180,9 @@ tasks.register<Exec>("exportProtovalidateModule") {
166180}
167181
168182tasks.register<Exec >(" generateSources" ) {
169- dependsOn(" exportProtovalidateModule" )
183+ dependsOn(" exportProtovalidateModule" , " filterBufGenYaml " )
170184 description = " Generates sources for the bufbuild/protovalidate module sources to build/generated/sources/bufgen."
171- commandLine(buf.asPath, " generate" , " --template" , " buf.gen.yaml" , " src/main/resources" )
185+ commandLine(buf.asPath, " generate" , " --template" , " ${layout.buildDirectory.get()} /buf-gen-templates/ buf.gen.yaml" , " src/main/resources" )
172186}
173187
174188tasks.register(" generate" ) {
0 commit comments