|
11 | 11 | * Except for legacy enums in the 'legacyEnums' whitelist, all newly defined Enums MUST reserve index 0 for a field starting with 'UNKNOWN_'. |
12 | 12 | * This ensures robust forward/backward compatibility during proto3 JSON serialization. |
13 | 13 | */ |
| 14 | +import groovy.json.JsonBuilder |
14 | 15 | import groovy.json.JsonSlurper |
15 | 16 | import org.gradle.internal.os.OperatingSystem |
16 | 17 |
|
@@ -39,10 +40,18 @@ task protoLint { |
39 | 40 | // 2. generateProto: fix Gradle implicit dependency warning due to output directory overlap. |
40 | 41 | dependsOn 'extractIncludeProto', 'generateProto' |
41 | 42 |
|
42 | | - // Incremental build support: Only run if proto files or the script itself changes |
| 43 | + // Wire the include proto directory from the extractIncludeProto task's actual output |
| 44 | + def extractTask = tasks.named('extractIncludeProto').get() |
| 45 | + def includeProtoDir = extractTask.destDir.get().asFile |
| 46 | + def includeProtoDirRel = projectDir.toPath().relativize(includeProtoDir.toPath()).toString() |
| 47 | + |
| 48 | + // Incremental build support: re-run when any file buf physically reads changes. |
| 49 | + // Include protos are not lint targets, but buf reads them for import resolution, |
| 50 | + // so they must be declared as inputs to keep the task cache hermetic. |
43 | 51 | inputs.dir('src/main/protos') |
| 52 | + inputs.dir(includeProtoDir) |
44 | 53 | inputs.file('protoLint.gradle') |
45 | | - |
| 54 | + |
46 | 55 | def markerFile = file("${buildDir}/tmp/protoLint.done") |
47 | 56 | outputs.file(markerFile) |
48 | 57 |
|
@@ -86,7 +95,7 @@ task protoLint { |
86 | 95 |
|
87 | 96 | println "🔍 Generating Proto AST image using buf CLI..." |
88 | 97 |
|
89 | | - def bufConfig = '{"version":"v1beta1","build":{"roots":["src/main/protos","build/extracted-include-protos/main"]}}' |
| 98 | + def bufConfig = new JsonBuilder([version: "v1beta1", build: [roots: ["src/main/protos", includeProtoDirRel]]]).toString() |
90 | 99 |
|
91 | 100 | def execResult = exec { |
92 | 101 | commandLine bufExe.absolutePath, 'build', '.', '--config', bufConfig, '-o', "${imageFile.absolutePath}#format=json" |
|
0 commit comments