Go to file
2026-09-05 20:47:08 -04:00
api feat(api): package Kotlin bindings for Gradle consumers 2026-09-05 20:47:08 -04:00
gradle Initial commit 2026-06-16 11:24:56 -07:00
gradle-plugin feat(api): package Kotlin bindings for Gradle consumers 2026-09-05 20:47:08 -04:00
src/wasmWasiMain/kotlin/plugin feat(api): package Kotlin bindings for Gradle consumers 2026-09-05 20:47:08 -04:00
wit@160251fb0b IPC and AI goals 2026-08-10 13:09:01 -07:00
.gitignore feat(api): package Kotlin bindings for Gradle consumers 2026-09-05 20:47:08 -04:00
.gitmodules Initial commit 2026-06-16 11:24:56 -07:00
build.gradle.kts feat(api): package Kotlin bindings for Gradle consumers 2026-09-05 20:47:08 -04:00
gradle.properties Initial commit 2026-06-16 11:24:56 -07:00
gradlew Initial commit 2026-06-16 11:24:56 -07:00
gradlew.bat Initial commit 2026-06-16 11:24:56 -07:00
LICENSE-APACHE Relicense under MIT OR Apache-2.0 2026-08-15 10:54:40 -07:00
LICENSE-MIT Relicense under MIT OR Apache-2.0 2026-08-15 10:54:40 -07:00
plugin.wasm Initial commit 2026-06-16 11:24:56 -07:00
README.md feat(api): package Kotlin bindings for Gradle consumers 2026-09-05 20:47:08 -04:00
settings.gradle.kts feat(api): package Kotlin bindings for Gradle consumers 2026-09-05 20:47:08 -04:00
wasi_snapshot_preview1.reactor.wasm Initial commit 2026-06-16 11:24:56 -07:00

Pumpkin Plugin API for Kotlin

This repository builds the Kotlin bindings for Pumpkin plugins using WebAssembly (Wasm) components.

The api Gradle module is a publishable Kotlin/WASI library and generated-source snapshot. It generates the WIT bindings only while API maintainers build or publish the library; the consumer Gradle plugin will unpack that snapshot before compiling a plugin, so plugin authors do not install or run wit-bindgen.

The root component template remains available while the consumer Gradle plugin is being moved into gradle-plugin.

API maintainer requirements

Kotlin/Wasm + components it's still in it's early stages, and not as straightforward as could be. You will need to have several things installed for everything to work.

  • JDK 17 or later
    • To run Gradle 9.4
  • Rust
    • This is required only to build or publish the API, because wit-bindgen is built from a particular Kotlin-enabled fork.
    • You only need a default Rust install for your host platform. NOT for any WebAssembly targets

Building the API

Initialize the WIT submodule after cloning:

git submodule update --init --recursive

Publish a local development artifact with:

./gradlew :api:publishToMavenLocal

This generates the pumpkin package bindings under api/build/generated/, compiles them with the package-owned WIT export bridge, and publishes the KLIB plus a generated-source archive. The source archive includes the pinned WIT snapshot and Preview 1 reactor adapter needed to assemble a component.

repositories {
    mavenLocal()
    mavenCentral()
}

// The consumer Gradle plugin resolves the matching generated-source archive.

The API artifact exposes PumpkinPlugin and registerPlugin(...); plugin authors should implement and register that class rather than defining the generator-specific PluginRootFunctionsExportsImpl or MetadataImpl types.

Root template build

The original root template still builds a complete component with ./gradlew build. Gradle skips tool installation, binding generation, and component assembly when their declared inputs are unchanged. Use ./gradlew clean to remove generated build output; it intentionally retains the installed tool cache under tools/.

Updating the WIT

Keep an eye on github.com/Pumpkin-MC/pumpkin-plugin-wit

If you start getting errors like main ThreadId(01) pumpkin::plugin: Failed to load plugin from "./plugins\\my_plugin.wasm": Wasm plugin initialization error: plugin failed to load with error: component imports instance 'pumpkin:plugin/gui@0.1.0', but a matching implementation was not found in the linker or other "linker" errors when loading your plugin into Pumpkin, update the wit submodule

cd wit
git pull origin master
cd ..

Attributions

This template was primarily derived from @jmrtsh's work on Kotlin/sample-wasi-http-kotlin, which is licensed under Apache-2.0