Building Tuoni Plugins
Build and run the Tuoni server with JDK 27, or use the supplied server container.
Classloader isolation
In order to avoid classpath conflicts between different plugins, Tuoni server loads each plugin with an isolated class loader so that the plugin has access to the JVM standard library and few allowlisted libraries, but does not see server’s own classes/dependencies nor the classes of other plugins. Due to this, every plugin must bundle all of its dependencies into single uber jar. When using Gradle, it is recommended to use shadow plugin. For Maven, use maven-shade-plugin.
Gradle development plugin
The Tuoni server source includes the com.shelldot.tuoni.plugin-development
Gradle plugin. It can bundle runtime dependencies, write Tuoni manifest fields,
and generate Java configuration records, parsers, and validators from schema
resources. It requires Gradle 9.8 or newer on Java 21 or newer. For a local
checkout, copy its tuoni-gradle-plugin directory into the plugin project and
include that build in settings.gradle.kts:
Apply and configure it in build.gradle.kts:
Put configuration schemas in src/main/resources/configuration_schemas.
Generation supplies a record, parser, validator, and schema() accessor by
default when schemas are present. Generated parsing uses Jackson, which your
plugin must declare as an implementation dependency. The SDK is
compileOnly because the server provides it; tests running generated APIs
need it on their runtime classpath. Keep the dependency versions compatible
with the server version you target. Run ./gradlew bundlePlugin and
install the resulting build/libs/<name>-<version>-all.jar; the regular JAR
does not include runtime dependencies. When consuming a published Gradle
plugin instead of a local included build, configure its repository and version
in Gradle's plugin management.
Currently, the only dependencies provided by the Tuoni server are:
- SLF4J for logging -
org.slf4j:slf4j-api - Tuoni SDK for plugin development -
com.shelldot:tuoni-plugin-sdk
These dependencies must not be bundled into the plugin jar, as they are provided by the server.
So these dependencies should have provided scope in Maven or compileOnly in Gradle.
Plugin discovery
Install custom plugins as regular .jar files directly inside the configured plugin
directories. Package the plugin's identity in MANIFEST.MF and its implementation
registrations in a service provider configuration file inside each JAR.
MANIFEST.MF
The manifest must contain the following entries:
Plugin-Id(Mandatory) - Mandatory unique text id to identify this plugin. It is strongly recommended to use the following naming scheme:$orgName.$pluginType.$pluginName. For example: “exampleorg.listener.http” or "myorg.command.ping"Plugin-Version(Mandatory) - Semver version of the plugin. Version can later be used for migrating configurations from older versions of the plugin to newer versionsPlugin-Provider(Optional) - Vendor/organisation/company/user who is the author and maintainer of the pluginPlugin-Name(Optional) - Name of the pluginPlugin-Description(Optional) - Description about what this plugin doesPlugin-Url(Optional) - URL to the source-code or distribution of the plugin.
ServiceLoader
The service provider configuration file follows Java ServiceLoader conventions, therefore there must exist a file under META-INF/services that is named after the plugin type that is implemented file and must contain the implementation class name of the custom plugin.
Plugin service paths for different plugin types:
- Command Plugin:
META-INF/services/com.shelldot.tuoni.plugin.sdk.command.CommandPlugin - Listener Plugin:
META-INF/services/com.shelldot.tuoni.plugin.sdk.listener.ListenerPlugin - Payload Plugin:
META-INF/services/com.shelldot.tuoni.plugin.sdk.payload.PayloadPlugin
Automation
The Tuoni Gradle development plugin generates the Tuoni manifest fields and merges service registrations into its bundled JAR. If building manually, use Google Auto Service for ServiceLoader registrations and configure the manifest in Gradle or Maven.
Shellcode
If the shellcode for the plugin is compiled ahead-of-time, then the binary for this shellcode should be bundled also inside the JAR file.
Keep in mind that Tuoni server is expected to run in an VM, container or environment that does not have any other tools/executables present, so compilation cannot occur inside the server code. In case dynamic compilation is needed, then this needs to be handled by creating a new separate service and implement communication between that service and the plugin. That however introduces friction to the end user since in addition to installing the plugin, they also need to spin up and configure your service. So such approach should only be used if strictly necessary.
Example build script
For a manual build, here is an example of a build script that bundles a JAR with dependencies and the built shellcode binary.