Skip to content

feat: enhance plugin file generation with JSON output and task improvements#211

Merged
twisti-dev merged 2 commits intoversion/1.21.11from
fix/gradle-problems
Feb 7, 2026
Merged

feat: enhance plugin file generation with JSON output and task improvements#211
twisti-dev merged 2 commits intoversion/1.21.11from
fix/gradle-problems

Conversation

@twisti-dev
Copy link
Contributor

This pull request refactors the Gradle plugin file generation logic to improve task cacheability and simplify serialization. The main changes involve switching from domain object serialization to direct JSON handling, updating task input/output properties, and ensuring tasks are cacheable. Additionally, dependency container creation and task registration have been modernized.

Plugin file generation refactoring:

  • Changed GeneratePluginFile to use a JSON string property (pluginFileJson) as input and a single file property (outputFile) as output, replacing domain object serialization and directory output. Task is now annotated as @CacheableTask for improved build caching.
  • Updated plugin file generation in CommonSurfPluginWithPluginFile to serialize plugin file objects to JSON before passing to the task, and to set the output file property accordingly.

Task and dependency container improvements:

  • Annotated GenerateLibrariesLoaderTask with @CacheableTask and added logic to delete the output directory before generation for correctness and cacheability. [1] [2]
  • Modernized dependency container creation in VelocityPluginFile to use project.objects.domainObjectContainer instead of the deprecated project.container.

Import and cleanup adjustments:

  • Cleaned up imports in generator files to reflect updated usage and remove unused references. [1] [2]

@twisti-dev twisti-dev self-assigned this Feb 7, 2026
Copilot AI review requested due to automatic review settings February 7, 2026 21:24
@twisti-dev twisti-dev merged commit 6f5b9c9 into version/1.21.11 Feb 7, 2026
3 of 4 checks passed
@twisti-dev twisti-dev deleted the fix/gradle-problems branch February 7, 2026 21:24
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ad100076e2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 28 to +29
@get:OutputDirectory
abstract val outputDirectory: DirectoryProperty
abstract val outputFile: RegularFileProperty

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Use OutputFile annotation for RegularFileProperty

The task now exposes outputFile as a RegularFileProperty, but it is still annotated with @OutputDirectory. Gradle validates output property types, so pairing @OutputDirectory with a regular file can cause configuration-time errors (e.g., “Expected a directory but found a file”) or incorrect up-to-date/caching behavior when the task writes a single file. This will surface whenever the task runs on a clean build or with configuration caching enabled. Use @OutputFile for a single file output to match the property type and task behavior.

Useful? React with 👍 / 👎.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the Gradle plugin’s plugin-file generation to improve cacheability by switching from domain object inputs to direct JSON inputs, and modernizes related task/container setup in the gradle plugin module.

Changes:

  • Refactor GeneratePluginFile to take a JSON string input and write to a single output file; mark the task cacheable.
  • Update CommonSurfPluginWithPluginFile to pre-serialize plugin file objects to JSON and wire a single output file.
  • Mark GenerateLibrariesLoaderTask cacheable and modernize VelocityPluginFile dependency container creation.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
surf-api-gradle-plugin/src/main/kotlin/dev/slne/surf/surfapi/gradle/platform/common/CommonSurfPluginWithPluginFile.kt Switches task wiring to pass JSON and a single output file to plugin-file generation.
surf-api-gradle-plugin/src/main/kotlin/dev/slne/surf/surfapi/gradle/generators/pluginfiles/VelocityPluginFile.kt Uses project.objects.domainObjectContainer for dependency container creation.
surf-api-gradle-plugin/src/main/kotlin/dev/slne/surf/surfapi/gradle/generators/LibrariesLoaderGenerator.kt Marks loader generation task as cacheable and cleans output before generating.
surf-api-gradle-plugin/src/main/kotlin/dev/slne/surf/surfapi/gradle/generators/GeneratePluginFile.kt Implements JSON-string based generation and changes output to a single file.

Comment on lines 27 to 30

@get:OutputDirectory
abstract val outputDirectory: DirectoryProperty
abstract val outputFile: RegularFileProperty

Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

outputFile is a RegularFileProperty but is annotated as @OutputDirectory. Gradle task property validation will treat this as an invalid output type and may fail the build / disable caching. Change the annotation (and import) to @OutputFile (with @get:OutputFile).

Copilot uses AI. Check for mistakes.
Comment on lines 22 to +26
@get:Input
abstract val fileName: Property<String>

@get:Nested
abstract val pluginFile: Property<CommonPluginFile>
@get:Input
abstract val pluginFileJson: Property<String>
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fileName is still declared as an @Input, but the task no longer uses it (the output path is fully determined by outputFile). This adds unnecessary configuration and affects the task cache key; consider removing fileName entirely or using it to derive outputFile inside the task configuration.

Copilot uses AI. Check for mistakes.
Comment on lines +35 to +39
group = "surf-api"

fileName.set(pluginFileName)

outputFile.set(generatedResourcesDirectory.map { it.file(pluginFileName) })
Copy link

Copilot AI Feb 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fileName is configured on GeneratePluginFile, but the task implementation no longer uses it (it writes to outputFile). Once fileName is removed/repurposed in the task, this configuration should be dropped to avoid misleading inputs.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant