Skip to content

Fix/plugin file generation#212

Merged
twisti-dev merged 2 commits into
version/1.21.11from
fix/plugin-file-generation
Feb 8, 2026
Merged

Fix/plugin file generation#212
twisti-dev merged 2 commits into
version/1.21.11from
fix/plugin-file-generation

Conversation

@twisti-dev

Copy link
Copy Markdown
Contributor

This pull request refactors the plugin file system in the Gradle plugin to improve type safety, serialization, and maintainability. The main changes include replacing direct serialization of plugin file classes with dedicated DTOs, updating property management to use Gradle's Property and ListProperty APIs, and simplifying the plugin extension and validation logic.

Plugin file and serialization refactor:

  • Introduced new DTO classes for plugin files (HytalePluginFileDto and VelocityPluginFileDto) to handle serialization, replacing custom serializers and direct annotation-based serialization in plugin file classes. (surf-api-gradle-plugin/src/main/kotlin/dev/slne/surf/surfapi/gradle/generators/pluginfiles/dto/HytalePluginFileDto.kt [1] surf-api-gradle-plugin/src/main/kotlin/dev/slne/surf/surfapi/gradle/generators/pluginfiles/dto/VelocityPluginFileDto.kt [2]
  • Removed custom serializers and serialization annotations from HytalePluginFile and VelocityPluginFile, and migrated their properties to use Gradle's Property, ListProperty, and MapProperty APIs for better integration with Gradle's configuration and task system. (surf-api-gradle-plugin/src/main/kotlin/dev/slne/surf/surfapi/gradle/generators/pluginfiles/HytalePluginFile.kt [1] surf-api-gradle-plugin/src/main/kotlin/dev/slne/surf/surfapi/gradle/generators/pluginfiles/VelocityPluginFile.kt [2]
  • Updated the plugin infrastructure to require a DTO serializer and a method to convert plugin files to DTOs, enabling a more robust and explicit serialization pipeline. (surf-api-gradle-plugin/src/main/kotlin/dev/slne/surf/surfapi/gradle/platform/common/CommonSurfPluginWithPluginFile.kt [1] [2]

Codebase simplification and cleanup:

  • Removed unused imports and obsolete serialization logic from several files, including GeneratePluginFile.kt, CommonPluginFile.kt, and others, reducing complexity and technical debt. (surf-api-gradle-plugin/src/main/kotlin/dev/slne/surf/surfapi/gradle/generators/GeneratePluginFile.kt [1] [2] surf-api-gradle-plugin/src/main/kotlin/dev/slne/surf/surfapi/gradle/generators/pluginfiles/CommonPluginFile.kt [3]
  • Refactored plugin extension creation to use class references instead of factory methods, simplifying extension registration in the plugin system. (surf-api-gradle-plugin/src/main/kotlin/dev/slne/surf/surfapi/gradle/platform/common/CommonSurfPlugin.kt [1] [2]

Version update:

@twisti-dev twisti-dev self-assigned this Feb 8, 2026
Copilot AI review requested due to automatic review settings February 8, 2026 12:56
@twisti-dev twisti-dev merged commit bd361b0 into version/1.21.11 Feb 8, 2026
8 checks passed
@twisti-dev twisti-dev deleted the fix/plugin-file-generation branch February 8, 2026 12:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 Gradle plugin-file generation to improve type safety and serialization clarity by introducing DTO-based serialization and migrating plugin-file models to Gradle Property APIs, while also simplifying extension registration.

Changes:

  • Introduce serializable DTOs (HytalePluginFileDto, VelocityPluginFileDto) and serialize DTOs instead of plugin-file model objects.
  • Migrate HytalePluginFile / VelocityPluginFile to Gradle Property/ListProperty/MapProperty-based models and adjust plugin wiring accordingly.
  • Simplify plugin extension creation by switching from factory methods to extensionClass, and bump gradle-plugin version suffix to -1.12.0.

Reviewed changes

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

Show a summary per file
File Description
surf-api-gradle-plugin/src/main/kotlin/dev/slne/surf/surfapi/gradle/platform/velocity/VelocitySurfPlugin.kt Wires Velocity plugin-file creation + DTO serializer into the common generation pipeline.
surf-api-gradle-plugin/src/main/kotlin/dev/slne/surf/surfapi/gradle/platform/hytale/HytaleSurfPlugin.kt Wires Hytale plugin-file creation + DTO serializer into the common generation pipeline.
surf-api-gradle-plugin/src/main/kotlin/dev/slne/surf/surfapi/gradle/platform/standalone/StandaloneSurfPlugin.kt Updates standalone plugin to new extensionClass-based extension creation.
surf-api-gradle-plugin/src/main/kotlin/dev/slne/surf/surfapi/gradle/platform/paper/raw/RawPaperSurfPlugin.kt Updates raw paper plugin to new extensionClass-based extension creation.
surf-api-gradle-plugin/src/main/kotlin/dev/slne/surf/surfapi/gradle/platform/paper/plugin/PaperPluginSurfPlugin.kt Updates paper plugin to new extensionClass-based extension creation.
surf-api-gradle-plugin/src/main/kotlin/dev/slne/surf/surfapi/gradle/platform/core/CoreSurfPlugin.kt Updates core plugin to new extensionClass-based extension creation.
surf-api-gradle-plugin/src/main/kotlin/dev/slne/surf/surfapi/gradle/platform/common/CommonSurfPlugin.kt Replaces createExtension(...) factory with extensionClass and extensions.create(...).
surf-api-gradle-plugin/src/main/kotlin/dev/slne/surf/surfapi/gradle/platform/common/CommonSurfPluginWithPluginFile.kt Switches plugin-file generation to encode DTOs using a provided SerializationStrategy.
surf-api-gradle-plugin/src/main/kotlin/dev/slne/surf/surfapi/gradle/generators/pluginfiles/dto/VelocityPluginFileDto.kt Adds Velocity DTO and mapping from VelocityPluginFile.
surf-api-gradle-plugin/src/main/kotlin/dev/slne/surf/surfapi/gradle/generators/pluginfiles/dto/HytalePluginFileDto.kt Adds Hytale DTO and mapping from HytalePluginFile.
surf-api-gradle-plugin/src/main/kotlin/dev/slne/surf/surfapi/gradle/generators/pluginfiles/VelocityPluginFile.kt Converts Velocity plugin-file model to Gradle managed properties + container-based deps.
surf-api-gradle-plugin/src/main/kotlin/dev/slne/surf/surfapi/gradle/generators/pluginfiles/HytalePluginFile.kt Converts Hytale plugin-file model to Gradle managed properties.
surf-api-gradle-plugin/src/main/kotlin/dev/slne/surf/surfapi/gradle/generators/pluginfiles/CommonPluginFile.kt Removes direct serialization support and old setDefaults hook from common base.
surf-api-gradle-plugin/src/main/kotlin/dev/slne/surf/surfapi/gradle/generators/GeneratePluginFile.kt Removes the no-longer-needed container serializer helper.
surf-api-gradle-plugin/build.gradle.kts Bumps plugin version suffix from -1.11.8 to -1.12.0.

override fun createPluginFile(project: Project) = VelocityPluginFile(project)
override fun createPluginFile(
project: Project
) = project.extensions.create<VelocityPluginFile>("velocityPluginFile").apply {

Copilot AI Feb 8, 2026

Copy link

Choose a reason for hiding this comment

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

createPluginFile uses extensions.create<VelocityPluginFile>("velocityPluginFile"). CommonSurfPluginWithPluginFile.apply() also registers the returned plugin file under the name velocityPluginFile ("${platformName}PluginFile"), which will cause a duplicate-extension error when applying the plugin. Instantiate the plugin file without registering it (e.g. project.objects.newInstance(...)), or remove the second registration in CommonSurfPluginWithPluginFile.

Suggested change
) = project.extensions.create<VelocityPluginFile>("velocityPluginFile").apply {
) = project.objects.newInstance(VelocityPluginFile::class.java).apply {

Copilot uses AI. Check for mistakes.
override fun createPluginFile(project: Project) = HytalePluginFile(project)
override fun createPluginFile(
project: Project
) = project.extensions.create<HytalePluginFile>("hytalePluginFile").apply {

Copilot AI Feb 8, 2026

Copy link

Choose a reason for hiding this comment

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

createPluginFile registers a HytalePluginFile extension named hytalePluginFile via extensions.create(...), but CommonSurfPluginWithPluginFile.apply() also adds the returned plugin file to extensions under the same name ("${platformName}PluginFile" -> hytalePluginFile). This will fail at runtime due to duplicate extension names. Consider creating the plugin file instance without registering it (e.g. project.objects.newInstance(...)) or removing the second registration in CommonSurfPluginWithPluginFile.

Suggested change
) = project.extensions.create<HytalePluginFile>("hytalePluginFile").apply {
) = project.objects.newInstance(HytalePluginFile::class.java).apply {

Copilot uses AI. Check for mistakes.
Comment on lines +54 to +58
fun fromFile(file: HytalePluginFile) = HytalePluginFileDto(
group = file.group.get(),
name = file.name.get(),
version = file.version.get(),
description = file.description.get(),

Copilot AI Feb 8, 2026

Copy link

Choose a reason for hiding this comment

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

HytalePluginFileDto.fromFile(...) never populates the id field (serializes as "Id"), even though HytalePluginFile has an id property and HytaleSurfPlugin sets a convention for it. This will generate manifests with a missing/null Id. Map file.id into the DTO (and decide whether it should be required vs optional).

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.

2 participants