Skip to content

KRPC-598: Use RegularFileProperty/DirectoryProperty for buf task outputs#714

Merged
Mr3zee merged 2 commits into
mainfrom
task/KRPC-598
May 6, 2026
Merged

KRPC-598: Use RegularFileProperty/DirectoryProperty for buf task outputs#714
Mr3zee merged 2 commits into
mainfrom
task/KRPC-598

Conversation

@ai-agent-kxrpc
Copy link
Copy Markdown
Contributor

@ai-agent-kxrpc ai-agent-kxrpc Bot commented May 5, 2026

Subsystem

gradle-plugin (Buf code-generation tasks)

Problem

YouTrack: KRPC-598

Solution

Migrates the three Buf task output properties in gradle-plugin from the generic Property<File> to the idiomatic typed forms:

Class Property Old type New type
GenerateBufYaml bufFile (@OutputFile) Property<File> RegularFileProperty
GenerateBufGenYaml bufGenFile (@OutputFile) Property<File> RegularFileProperty
BufGenerateTask outputDirectory (@OutputDirectory) Property<File> DirectoryProperty

Caller-side wiring (registerGenerateBufYamlTask, registerGenerateBufGenYamlTask, registerBufGenerateTask) now uses project.layout.file(project.provider { ... }) and project.layout.dir(project.provider { ... }) to feed the local File into convention(...). This is the canonical convention-with-File idiom — FileSystemLocationProperty has no conventionFileValue(File). Read sites inside @TaskAction switch from .get() (which returned File) to .get().asFile (which returns File from the new RegularFile / Directory value).

The gradle-plugin/api/gradle-plugin.api ABI dump is regenerated as a separate commit so the mechanical change is visible in isolation.

⚠️ Breaking change (ABI + DSL)

Three public abstract task-property getters change return type:

  • BufGenerateTask.getOutputDirectory(): Property<File>DirectoryProperty
  • GenerateBufGenYaml.getBufGenFile(): Property<File>RegularFileProperty
  • GenerateBufYaml.getBufFile(): Property<File>RegularFileProperty

The new return types are subtypes of Property so source code that reads the property (e.g. task.outputDirectory.get()) keeps working at the value level. Source-incompatible cases:

  • Code that explicitly typed the property as Property<File> (e.g. val p: Property<File> = task.outputDirectory) needs to switch to DirectoryProperty / RegularFileProperty.
  • Bytecode that called getOutputDirectory() against the old descriptor will get NoSuchMethodError and must be recompiled.

The Kotlin DSL outputDirectory = file("...") and outputDirectory.set(file("...")) patterns continue to compile because Gradle 8.2+ ships FileSystemLocationProperty.set(File) and .assign(File?). No .fileValue(File) migration is required for users who already used those forms.

This is a pre-1.0 dev-preview line; per the analysis on the YouTrack ticket no deprecation shim is added (single-getter surface, nothing to soft-deprecate side-by-side). The breaking change should be called out in the next release CHANGELOG section by the release maintainer — this project does not maintain an in-tree Unreleased section.

Verification

  • :gradle-plugin:compileKotlin
  • :gradle-plugin:updateLegacyAbi regenerated cleanly; checkLegacyAbi
  • detekt ✓ (no new violations)
  • :gradle-plugin:test — 205/205 TestKit integration tests pass (exercise bufGenerateCommonMain end-to-end across JVM/KMP/Android scenarios)
  • :protobuf:protobuf-wkt:bufGenerateCommonMain and :tests:protobuf-conformance:bufGenerateCommonMain ✓ — confirms the two internal call sites that use outputDirectory = file (Kotlin-DSL assign-operator, type-erased) still compile and execute correctly against DirectoryProperty

Note

Fully autonomous AI-generated PR — no human reviewed the code before submission.
Problem analysis and root cause details: KRPC-598

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 5, 2026

🔒 AI PR Safety: SAFE

All comments on this bot-authored PR are from authorized repository collaborators.

@ai-agent-kxrpc ai-agent-kxrpc Bot added infra Infrastructure changes (Gradle, CI, project setup, etc) breaking Contains breaking changes labels May 5, 2026
@ai-agent-kxrpc
Copy link
Copy Markdown
Contributor Author

ai-agent-kxrpc Bot commented May 5, 2026

Internal code review

Items flagged during automated code review but not fixed in this PR.
Check the box to request a fix:

Gradle correctness reviewer

  • gradle-plugin/src/main/kotlin/kotlinx/rpc/buf/tasks/BufGenerateTask.kt:155,173 — (nit) Function parameter outputDirectory: File shadows the task property this.outputDirectory. The shadowing is pre-existing (the parameter had this name before this PR). Renaming the parameter (e.g. outputDir) at line 155 and the lambda capture at line 173 would remove the ambiguity, but is outside the migration's minimal scope.

Cross-cutting risk reviewer

  • tests/protobuf-conformance/build.gradle.kts:79, protobuf/protobuf-wkt/build.gradle.kts:48 — (warning) Both call sites use outputDirectory = generatedCodeDir(...) (Kotlin-DSL assign-operator with File). Verified to compile and execute correctly against the new DirectoryProperty via Gradle's FileSystemLocationProperty.assign(File?) extension (Gradle 8.2+, project's minimum tested Gradle is 8.8). Reviewer suggested a comment at those sites or an explicit .set(layout.projectDirectory.dir(...)) form for clarity. Skipped to keep the diff scoped to the ticket.
  • gradle-plugin/src/main/kotlin/kotlinx/rpc/protoc/DefaultProtocExtension.kt:273 — (nit) Same parameter-shadowing pattern as the BufGenerateTask reviewer flag. Pre-existing.

No errors were flagged by either reviewer. The full diff was reviewed against ABI compatibility, configuration cache safety, lazy-evaluation semantics, and downstream consumer impact.

@ai-agent-kxrpc
Copy link
Copy Markdown
Contributor Author

ai-agent-kxrpc Bot commented May 5, 2026

CI Report

Passed

Pipeline Details
TC: All Gradle Plugin (composite) build #54640
TC: Gradle Plugin Test build #54637
TC: Gradle Plugin CheckApi build #54638
TC: Gradle Plugin Detekt build #54639
GH: AI PR Safety Check pass
GH: Bot PR Title Format pass
GH: Run Verification ×7 all green (example run)

Failed

None

@ai-agent-kxrpc ai-agent-kxrpc Bot marked this pull request as ready for review May 5, 2026 20:15
@ai-agent-kxrpc ai-agent-kxrpc Bot requested a review from Mr3zee May 5, 2026 20:15
@Mr3zee Mr3zee merged commit 3c3c6f0 into main May 6, 2026
18 checks passed
@Mr3zee Mr3zee deleted the task/KRPC-598 branch May 6, 2026 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Contains breaking changes infra Infrastructure changes (Gradle, CI, project setup, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant