Skip to content

Add canvas-plugin Gradle plugin module#239

Open
Copilot wants to merge 4 commits intoversion/1.21.11from
copilot/add-canvas-plugin-module
Open

Add canvas-plugin Gradle plugin module#239
Copilot wants to merge 4 commits intoversion/1.21.11from
copilot/add-canvas-plugin-module

Conversation

Copy link
Contributor

Copilot AI commented Mar 10, 2026

Adds a new dev.slne.surf.surfapi.gradle.canvas-plugin Gradle plugin for Canvas server targets, inheriting all paper-plugin behaviour (plugin.yml generation, runServer, surf-api wiring) while substituting canvas-api as the compile target and resolving the org.bukkit:bukkit capability conflict in favour of Canvas.

Changes

  • AbstractPaperPluginSurfPlugin<E> — extracted paper-plugin logic from PaperPluginSurfPlugin into a generic abstract base; PaperPluginSurfPlugin now delegates to it unchanged
  • CanvasSurfExtension — extends PaperPluginSurfExtension, inheriting all existing DSL methods; defaults foliaSupported to true (can be overridden explicitly)
  • CanvasPluginSurfPlugin — extends AbstractPaperPluginSurfPlugin<CanvasSurfExtension>; overrides applyRepositories0() to add the Canvas Maven snapshot repo and configure0() to add canvas-api + capability resolution
  • canvasMaven() — new RepositoryHandler extension in repo-extensions.kt, mirrors the existing slnePublic() pattern
  • libs.versions.toml / Constants.ktcanvas-api version managed via version catalog and exposed as Constants.CANVAS_API
  • build.gradle.kts — registers dev.slne.surf.surfapi.gradle.canvas-plugin

Usage

plugins {
    id("dev.slne.surf.surfapi.gradle.canvas-plugin")
}

surfCanvasPluginApi {
    mainClass("com.example.MyPlugin")
    bootstrapper("com.example.MyBootstrap")
    authors.add("yourname")
}

Canvas plugins have foliaSupported enabled by default. The capability resolution ensures canvas-api wins when transitive dependencies pull in paper-api or plain bukkit:

configurations.all {
    resolutionStrategy.capabilitiesResolution.withCapability("org.bukkit:bukkit") {
        select(Constants.CANVAS_API)
    }
}

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: TheBjoRedCraft <143264463+TheBjoRedCraft@users.noreply.github.com>
Copilot AI changed the title [WIP] Add canvas plugin module to gradle configuration Add canvas-plugin Gradle plugin module Mar 10, 2026
@TheBjoRedCraft
Copy link
Member

@copilot jedes canvas plugin soll foliaSupported(true) haben

Co-authored-by: TheBjoRedCraft <143264463+TheBjoRedCraft@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 10, 2026

@copilot jedes canvas plugin soll foliaSupported(true) haben

CanvasSurfExtension now overrides the foliaSupported convention to true in its init block, so every canvas plugin has Folia support enabled by default (can still be overridden explicitly). Done in 1c7e8af.

@TheBjoRedCraft TheBjoRedCraft marked this pull request as ready for review March 10, 2026 17:30
Copilot AI review requested due to automatic review settings March 10, 2026 17:30
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

Adds first-class Gradle plugin support for Canvas server targets within the existing surf-api-gradle-plugin module, reusing the Paper plugin implementation while swapping the compile target to canvas-api and handling org.bukkit:bukkit capability conflicts.

Changes:

  • Extracted shared Paper plugin behavior into AbstractPaperPluginSurfPlugin and made PaperPluginSurfPlugin delegate to it.
  • Introduced canvas-plugin Gradle plugin + DSL extension with foliaSupported = true by default.
  • Added Canvas repository helper + version-catalog/Constants wiring for canvas-api.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
surf-api-gradle-plugin/src/main/kotlin/dev/slne/surf/surfapi/gradle/util/repo-extensions.kt Adds canvasMaven() repository helper for Canvas snapshots.
surf-api-gradle-plugin/src/main/kotlin/dev/slne/surf/surfapi/gradle/platform/paper/plugin/PaperPluginSurfPlugin.kt Refactors Paper plugin to extend the new shared abstract base.
surf-api-gradle-plugin/src/main/kotlin/dev/slne/surf/surfapi/gradle/platform/paper/plugin/AbstractPaperPluginSurfPlugin.kt New shared implementation for Paper-style plugin.yml + runServer wiring.
surf-api-gradle-plugin/src/main/kotlin/dev/slne/surf/surfapi/gradle/platform/canvas/CanvasSurfExtension.kt New Canvas DSL extension inheriting Paper DSL and defaulting foliaSupported to true.
surf-api-gradle-plugin/src/main/kotlin/dev/slne/surf/surfapi/gradle/platform/canvas/CanvasPluginSurfPlugin.kt New Canvas plugin: adds Canvas repo, canvas-api dependency, and capability selection.
surf-api-gradle-plugin/build.gradle.kts Registers the new Gradle plugin, bumps version, and exposes CANVAS_API in generated constants.
surf-api-gradle-plugin/README.md Documents the new dev.slne.surf.surfapi.gradle.canvas-plugin ID.
gradle/libs.versions.toml Adds canvas-api version + library alias.

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.

3 participants