Fix/plugin file generation#215
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the surf-api-gradle-plugin to refactor plugin file generation so the generator task is configured via an output directory + file name, and bumps the plugin version for release tracking.
Changes:
- Refactored
GeneratePluginFileto use@OutputDirectory outputDirplus@Input fileNameinstead of a single@OutputFile. - Updated common plugin setup to configure the generator task with the generated resources directory.
- Bumped
surf-api-gradle-pluginversion from-1.12.2to-1.12.3.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| surf-api-gradle-plugin/src/main/kotlin/dev/slne/surf/surfapi/gradle/platform/common/CommonSurfPluginWithPluginFile.kt | Updates task configuration to set outputDir instead of outputFile. |
| surf-api-gradle-plugin/src/main/kotlin/dev/slne/surf/surfapi/gradle/generators/GeneratePluginFile.kt | Changes task outputs to a directory + file name and adjusts write/delete logic accordingly. |
| surf-api-gradle-plugin/build.gradle.kts | Increments plugin version suffix to 1.12.3. |
| val outFile = outputDir.file(fileName).get().asFile | ||
| val json = pluginFileJson.get() | ||
|
|
||
| if (json.isNotBlank()) { | ||
| out.parentFile.mkdirs() | ||
| out.writeText(json) | ||
| } else { | ||
| if (out.exists()) out.delete() | ||
| if (json.isBlank()) { | ||
| if (outFile.exists()) outFile.delete() | ||
| return | ||
| } | ||
|
|
||
| outFile.parentFile.mkdirs() | ||
| outFile.writeText(json) |
There was a problem hiding this comment.
GeneratePluginFile now declares an @OutputDirectory but only deletes the specific outFile when pluginFileJson is blank. If fileName changes across builds (or older outputs exist), stale files can remain in outputDir and be picked up as resources, and it also makes the @CacheableTask output less deterministic. Consider cleaning outputDir at the start of the task (similar to GenerateLibrariesLoaderTask), or switch back to an @OutputFile that is derived from outputDir + fileName so Gradle tracks a single output file.
This pull request updates the
surf-api-gradle-pluginto improve plugin file generation and bump the plugin version. The main changes involve switching the plugin file generation task from outputting a single file to specifying an output directory and file name separately, which simplifies configuration and improves flexibility.Version update:
1.12.2to1.12.3inbuild.gradle.ktsfor improved release tracking.Plugin file generation improvements:
GeneratePluginFiletask to use an output directory (DirectoryProperty) and file name (Property<String>) instead of an output file (RegularFileProperty). This change streamlines how the generated plugin file is specified and written.CommonSurfPluginWithPluginFile.ktto set the output directory instead of the output file, aligning with the refactored task interface.