Skip to Content
Taffy

Gradle plugins

The seven Taffy Gradle plugins, what each applies and configures, and the alaz version catalog they expose.

Taffy ships Gradle plugins, published together as so.alaz.taffy:taffy-gradle, and a version catalog, published as so.alaz.taffy:taffy-catalog. Together they give a plugin build the repositories it resolves from, the Java 25 toolchain, test defaults that catch locale and time zone bugs, a coverage gate on check, one relocated shadow jar for the server, and the RuntimeLibraries class a PluginLoader reads its downloads from.

Plugin idApplied inAppliesAdds
so.alaz.taffy.settingssettings.gradle.ktsso.alaz.taffy.repositoriesThe alaz version catalog, at the plugin's own version
so.alaz.taffy.repositoriessettings.gradle.ktsthe foojay toolchain resolverMaven Central, Paper, repo.alaz.so and the integration repositories
so.alaz.taffy.javaany Java modulejava-libraryJava 25 toolchain, compiler and javadoc flags, JUnit Platform, test defaults, LICENSE in META-INF
so.alaz.taffy.coverageany Java moduleso.alaz.taffy.java, jacocoThe coverage extension and an instruction coverage gate on check
so.alaz.taffy.paper-pluginthe plugin moduleso.alaz.taffy.coverage, com.gradleup.shadowThe paperPlugin extension, the relocated shadow jar, ${version} expansion in paper-plugin.yml
so.alaz.taffy.paper-apia published API moduleso.alaz.taffy.java, maven-publishSources and javadoc jars, the library publication and the alazso repository
so.alaz.taffy.librarya published, tested library moduleso.alaz.taffy.paper-api, so.alaz.taffy.coverageA per-class coverage floor of 0.50

A Paper plugin usually needs only two of them: so.alaz.taffy.settings in settings.gradle.kts and so.alaz.taffy.paper-plugin in build.gradle.kts.

Applying the plugins

The settings plugin is the one applied with a version. It puts every Taffy plugin on the build's classpath, so project build scripts apply the others by id alone.

settings.gradle.kts
pluginManagement {
    repositories {
        maven("https://repo.alaz.so/releases")
        gradlePluginPortal()
    }
}

plugins {
    id("so.alaz.taffy.settings") version "0.1.0"
}

rootProject.name = "myplugin"
build.gradle.kts
plugins {
    id("so.alaz.taffy.paper-plugin")
}

dependencies {
    compileOnly(alaz.paper.api)
    implementation(alaz.taffy.platform)
    testImplementation(alaz.junit.jupiter)
    testRuntimeOnly(alaz.junit.platform.launcher)
}
gradle.properties
group=com.example.myplugin
version=1.0.0

The plugins are Java 25 class files loaded into Gradle's own JVM, so Gradle itself runs on Java 25. A file gradle/gradle-daemon-jvm.properties holding toolchainVersion=25 makes Gradle pick a Java 25 JVM whatever JAVA_HOME points to. Every push to Taffy's main branch publishes the next version as a -SNAPSHOT to https://repo.alaz.so/snapshots; a build that uses a snapshot adds that repository to pluginManagement.repositories. Getting started covers building against a local publish.

so.alaz.taffy.settings

Applies so.alaz.taffy.repositories and creates the version catalog alaz from so.alaz.taffy:taffy-catalog at the same version as the plugin. Applying so.alaz.taffy.settings version 0.1.0 gives catalog 0.1.0, which in turn pins every Taffy module to 0.1.0. The plugins, the catalog and the runtime modules share one version, as Versioning describes. The catalog's aliases are listed at the end of this page.

so.alaz.taffy.repositories

Applies org.gradle.toolchains.foojay-resolver-convention, so Gradle downloads a Java 25 toolchain when the machine has none, and declares these repositories in dependencyResolutionManagement, in this order:

NameURLContent
MavenRepoMaven Centraleverything
papermchttps://repo.papermc.io/repository/maven-public/everything
alazsohttps://repo.alaz.so/releasesreleases of the so.alaz group and its subgroups only
alazsoSnapshotshttps://repo.alaz.so/snapshotssnapshots of the so.alaz group and its subgroups only
placeholderapihttps://repo.extendedclip.com/releases/everything
faststatshttps://repo.faststats.dev/releaseseverything
jitpackhttps://jitpack.ioeverything
vaultunlockedhttps://repo.codemc.io/repository/creatorfromhell/everything
playerpointshttps://repo.rosewooddev.io/repository/public/everything
oraxenhttps://repo.oraxen.com/releaseseverything
nexohttps://repo.nexomc.com/releaseseverything
enginehubhttps://maven.enginehub.org/repo/everything

The plugin sets RepositoriesMode.PREFER_SETTINGS: Gradle ignores a repository declared in a project build script. A build that needs another repository declares it in settings.gradle.kts:

settings.gradle.kts
dependencyResolutionManagement {
    repositories {
        maven("https://repo.example.org/releases") { name = "example" }
    }
}

so.alaz.taffy.repositories creates no version catalog. A build that wants the repositories without the alaz catalog applies it instead of so.alaz.taffy.settings.

so.alaz.taffy.java

Applies java-library and sets the conventions every Taffy module and plugin build compiles and tests under.

AreaSetting
Toolchainjava.toolchain.languageVersion 25
JavaCompileoptions.encoding = "UTF-8", compiler argument -Xlint:all,-processing,-serial (warnings, the build does not fail on them)
Javadoc-Xdoclint:all,-missing, -quiet, --no-fonts, UTF-8 encoding
TestuseJUnitPlatform(), logs passed, skipped and failed events, Mockito agent, test locale and time zone
JarThe root project's LICENSE file in META-INF

Javadoc

Doclint runs with every group except missing. A public member without a comment passes, and a broken comment fails the javadoc task, for example an @param that names no parameter of the method. --no-fonts keeps the web fonts out of the generated javadoc.

Test locale and time zone

Every Test task runs with these system properties:

PropertyValue
user.languagetr
user.countryTR
user.timezonePacific/Auckland

Under the Turkish locale, "TITLE".toLowerCase() gives a dotless ı, so code that reads the default locale instead of passing Locale.ROOT fails in a test instead of on a server. Auckland is ahead of UTC, so code that reads an instant late in the UTC day in the default zone gets the next day. A test task replaces a default with systemProperty:

build.gradle.kts
tasks.test {
    systemProperty("user.language", "en")
}

Mockito agent

Each test task passes every mockito-core-*.jar on its own classpath to the test JVM as -javaagent, so Mockito's inline mock maker is loaded at JVM start and does not attach itself to the running JVM. The classpath is read when the task runs, so a test task or source set the build adds later gets the agent from its own classpath. A test task without Mockito on its classpath gets no agent argument. The agent sits beside the JaCoCo agent that so.alaz.taffy.coverage adds. taffy-test declares mockito-core as an implementation dependency, so it is on the test runtime classpath of a plugin that declares testImplementation(alaz.taffy.test), and that test task gets the agent. Test code that calls Mockito itself declares testImplementation(alaz.mockito.core), because a runtime dependency of taffy-test is not on the test compile classpath.

LICENSE

Every Jar task (the plain jar, the sources and javadoc jars, and the shadow jar) copies the file LICENSE from the root project directory into META-INF. When the root project has no LICENSE, the jars build without one.

so.alaz.taffy.coverage

Applies so.alaz.taffy.java and jacoco, and adds the coverage extension (so.alaz.taffy.gradle.CoverageExtension).

PropertyTypeDefaultMeaning
minimumProperty<BigDecimal>0.80Instruction coverage the whole module must reach
classMinimumProperty<BigDecimal>0, and 0.50 under so.alaz.taffy.libraryInstruction coverage each class must reach. 0 turns the per-class rule off
exclusionsListProperty<String>emptyAnt patterns of class files left out of the gate, relative to the classes directory
conventionExclusionsListProperty<String>empty, **/RuntimeLibraries.class under so.alaz.taffy.paper-pluginPatterns other conventions add, applied in addition to exclusions
build.gradle.kts
coverage {
    minimum.set("0.70".toBigDecimal())
    classMinimum.set("0.40".toBigDecimal())
    exclusions.addAll("**/command/**", "**/hook/**", "com/example/myplugin/MyPluginLoader.class")
}

What the plugin wires:

  • Every Test task is finalized by jacocoTestReport, which writes XML and HTML reports.
  • jacocoTestCoverageVerification depends on test and checks the module's main classes, minus both exclusion lists, against a BUNDLE rule (INSTRUCTION, COVEREDRATIO, minimum) and, when classMinimum is above zero, a CLASS rule with classMinimum.
  • verifyCoverageData depends on test and fails when the module has classes under the gate, at least one of minimum and classMinimum is above zero, and no coverage data exists (build/jacoco/test.exec), which is the case when no test ran.
  • check, and so build, depends on jacocoTestCoverageVerification and verifyCoverageData.

The gate covers the module's own compiled classes only. Libraries that a shadow jar carries are not part of it.

A module with classes and no tests fails check in verifyCoverageData with the message No coverage data for <project path>: it has classes under the coverage gate but no test ran. Add tests, exclude the classes with coverage.exclusions, or set coverage.minimum and coverage.classMinimum to 0. The project path of a root project is :. A module without tests passes check once its classes are all excluded, or once both minimum and classMinimum are 0.

Set the minimums in the build script

minimum and classMinimum become JaCoCo rule limits in an afterEvaluate block, so the value a build script sets while it is evaluated is the one used. A value set in a later afterEvaluate or in a task action does not reach the rules. exclusions and conventionExclusions are read lazily, so a value set in a later afterEvaluate still applies.

An exclusion pattern matches class file names. A nested or anonymous class compiles to its own file such as Menu$Page.class or Menu$1.class, which the pattern **/Menu.class does not match; **/Menu*.class matches all three, and also any other class whose name starts with Menu.

so.alaz.taffy.paper-plugin

Applies so.alaz.taffy.coverage and Shadow (com.gradleup.shadow), and builds the one jar a server owner installs. It adds no dependency on Paper: the plugin declares compileOnly(alaz.paper.api) itself, and anything on compileOnly stays out of the shadow jar.

The shadow jar

TaskSetting
shadowJararchiveClassifier is empty, duplicatesStrategy = DuplicatesStrategy.EXCLUDE, relocations below
jardisabled
assembledepends on shadowJar

./gradlew build therefore leaves one file, build/libs/<project name>-<version>.jar, with no classifier. With DuplicatesStrategy.EXCLUDE, the first copy of a path wins, which keeps one META-INF/faststats.properties when several dependencies carry it.

Three packages are relocated under <group>.libs, where <group> is the project group:

PackageRelocated to
org.bstats<group>.libs.bstats
dev.faststats<group>.libs.faststats
so.alaz.taffy<group>.libs.taffy

With group=com.example.myplugin, Taffy's so.alaz.taffy.platform.Scheduler ships as com.example.myplugin.libs.taffy.platform.Scheduler. Each plugin carries its own copy of Taffy, so plugins built on different Taffy versions share no Taffy classes on one server. bStats refuses to start from classes that were not relocated, so a build that shades taffy-metrics without this plugin relocates the same three packages itself and keeps META-INF/faststats.properties in its shadow jar (metrics has the details).

com.comficonf is never relocated: the ComfiConf API comes from the installed bridge, and a plugin declares it compileOnly(alaz.comficonf.api) (ComfiConf). Any other library a plugin adds with implementation is shaded unrelocated unless the build adds its own relocate call:

build.gradle.kts
tasks.shadowJar {
    relocate("com.example.lib", "com.example.myplugin.libs.lib")
}

paper-plugin.yml

processResources expands ${version} in src/main/resources/paper-plugin.yml to the project version, and declares the version as a task input. No other descriptor key is written: name, main, api-version, loader, folia-supported and the dependencies come from the plugin's own file.

src/main/resources/paper-plugin.yml
name: MyPlugin
version: "${version}"
main: com.example.myplugin.MyPlugin

The file goes through Gradle's expand, and version is the only property defined. Another ${...} expression in it fails processResources.

Compiler flag

The plugin adds -Xlint:-classfile to every JavaCompile task. Some integration APIs are Kotlin-compiled and declared without their transitive dependencies, so the kotlin.* annotation types their class files name are absent; the flag keeps javac from warning about each of them.

Runtime libraries

The paperPlugin extension (so.alaz.taffy.gradle.PaperPluginExtension) lists the Maven coordinates Paper downloads before the plugin loads, in resolution order. taffy-storage needs it: it ships neither HikariCP nor any JDBC driver (storage).

MemberTypeMeaning
runtimeLibrariesListProperty<String>Coordinates as group:name:version
runtimeLibrary(library)takes Provider<MinimalExternalModuleDependency>Adds a version catalog entry as group:name:version
build.gradle.kts
dependencies {
    compileOnly(alaz.paper.api)
    implementation(alaz.taffy.storage)
    testImplementation(alaz.junit.jupiter)
    testRuntimeOnly(alaz.junit.platform.launcher)
    testRuntimeOnly(alaz.hikari)
    testRuntimeOnly(alaz.sqlite.jdbc)
}

paperPlugin {
    runtimeLibrary(alaz.hikari)
    runtimeLibrary(alaz.sqlite.jdbc)
    runtimeLibrary(alaz.mysql.connector)
    runtimeLibraries.add("org.example:extra:1.2.3")
}

The runtime libraries are not on any Gradle classpath. Tests that start storage declare HikariCP and each driver they use on testRuntimeOnly, as above.

When the list is not empty, the generateRuntimeLibraries task writes RuntimeLibraries.java to build/generated/sources/runtimeLibraries/java/main, a source directory of the main source set, in the package named by the project group. With group=com.example.myplugin and the block above it generates:

build/generated/sources/runtimeLibraries/java/main/com/example/myplugin/RuntimeLibraries.java
package com.example.myplugin;

import java.util.List;

/** Generated from the version catalog at build time. Do not edit. */
final class RuntimeLibraries {

    /** Maven coordinates of the libraries Paper downloads before the plugin loads. */
    static final List<String> COORDINATES = List.of(
        "com.zaxxer:HikariCP:7.1.0",
        "org.xerial:sqlite-jdbc:3.54.1.0",
        "com.mysql:mysql-connector-j:26.10.0",
        "org.example:extra:1.2.3");

    private RuntimeLibraries() {
    }
}

The class and its field are package-private, so the code that reads them lives in that same package. The project group becomes the package declaration as it is, so it must be a valid Java package name. With an empty list, no class is generated. **/RuntimeLibraries.class is in coverage.conventionExclusions, outside the gate.

The build does not register a loader. The plugin writes a Paper PluginLoader in the group package that hands the coordinates to Paper's MavenLibraryResolver:

src/main/java/com/example/myplugin/MyPluginLoader.java
package com.example.myplugin;

import io.papermc.paper.plugin.loader.PluginClasspathBuilder;
import io.papermc.paper.plugin.loader.PluginLoader;
import io.papermc.paper.plugin.loader.library.impl.MavenLibraryResolver;
import org.eclipse.aether.artifact.DefaultArtifact;
import org.eclipse.aether.graph.Dependency;
import org.eclipse.aether.repository.RemoteRepository;

public final class MyPluginLoader implements PluginLoader {

    @Override
    public void classloader(PluginClasspathBuilder classpathBuilder) {
        MavenLibraryResolver resolver = new MavenLibraryResolver();
        resolver.addRepository(new RemoteRepository.Builder(
                "central", "default", MavenLibraryResolver.MAVEN_CENTRAL_DEFAULT_MIRROR).build());
        for (String coordinates : RuntimeLibraries.COORDINATES) {
            resolver.addDependency(new Dependency(new DefaultArtifact(coordinates), null));
        }
        classpathBuilder.addLibrary(resolver);
    }
}
src/main/resources/paper-plugin.yml
loader: com.example.myplugin.MyPluginLoader

HikariCP and the drivers in the catalog are published on Maven Central, and MavenLibraryResolver.MAVEN_CENTRAL_DEFAULT_MIRROR is the Maven Central address Paper's API provides for a loader. The loader class is plugin code under the coverage gate like any other class; the coverage example above excludes it. Paper's documentation on plugin loaders covers the loader itself.

Never list the metrics SDKs

bStats and FastStats come as runtime dependencies of taffy-metrics and are shaded and relocated. Listing alaz.bstats.bukkit or alaz.faststats.bukkit as a runtime library makes Paper load an unrelocated copy.

so.alaz.taffy.paper-api

Applies so.alaz.taffy.java and maven-publish, for a module other plugins compile against, such as a plugin's public API.

myplugin-api/build.gradle.kts
plugins {
    id("so.alaz.taffy.paper-api")
}

description = "MyPlugin public API"

It adds no Paper dependency and no coverage gate. It configures:

  • java.withSourcesJar() and java.withJavadocJar().
  • A MavenPublication named library from the java component, published as <group>:<project name>:<version>. The POM name is the project name, the POM description is the project description, and the license is the MIT License.
  • The POM url from the Gradle property alaz.repositoryUrl, or https://github.com/alazso/<root project name> when the property is unset.
  • A Maven repository named alazso: https://repo.alaz.so/snapshots when the version ends with -SNAPSHOT, https://repo.alaz.so/releases otherwise.
gradle.properties
alaz.repositoryUrl=https://github.com/example/myplugin

The alazso repository takes its credentials from the environment variables ALAZSO_REPO_USER and ALAZSO_REPO_TOKEN. They are read with System.getenv, not as Gradle properties, so a -P flag or an entry in gradle.properties does not set them.

export ALAZSO_REPO_USER=...
export ALAZSO_REPO_TOKEN=...
./gradlew publishLibraryPublicationToAlazsoRepository

A build that publishes elsewhere adds its own repository next to alazso; Gradle then creates one publish task per repository, such as publishLibraryPublicationToExampleRepository:

myplugin-api/build.gradle.kts
publishing {
    repositories {
        maven("https://repo.example.org/releases") { name = "example" }
    }
}

publishToMavenLocal publishes the library publication to the local Maven repository with no credentials.

so.alaz.taffy.library

Applies so.alaz.taffy.paper-api and so.alaz.taffy.coverage, and sets the convention of coverage.classMinimum to 0.50. It is the plugin for a published library module with tests: every class under the gate holds at least half its instructions covered, and the module as a whole holds coverage.minimum (default 0.80). Every Taffy runtime module is built with it.

A class below the floor fails jacocoTestCoverageVerification with a message of the form Rule violated for class com.example.Demo: instructions covered ratio is 0.00, but expected minimum is 0.50. coverage.classMinimum.set("0".toBigDecimal()) turns the per-class rule off.

The alaz version catalog

so.alaz.taffy.settings exposes so.alaz.taffy:taffy-catalog as alaz. A dash in an alias becomes a dot in the accessor: alias paper-api is alaz.paper.api. Versions are read with alaz.versions.<key>, for example alaz.versions.paper (a Provider<String>).

Taffy modules

Each module has an entry at the catalog's own version, the version key taffy.

AccessorCoordinatesPage
alaz.taffy.platformso.alaz.taffy:taffy-platformplatform
alaz.taffy.configso.alaz.taffy:taffy-configconfig
alaz.taffy.storageso.alaz.taffy:taffy-storagestorage
alaz.taffy.hooksso.alaz.taffy:taffy-hookshooks
alaz.taffy.guiso.alaz.taffy:taffy-guigui
alaz.taffy.metricsso.alaz.taffy:taffy-metricsmetrics
alaz.taffy.comficonfso.alaz.taffy:taffy-comficonfcomficonf
alaz.taffy.testso.alaz.taffy:taffy-testtest

Paper, storage and metrics

AccessorCoordinatesVersion keyUsed as
alaz.paper.apiio.papermc.paper:paper-apipapercompileOnly
alaz.jetbrains.annotationsorg.jetbrains:annotationsannotationscompileOnly
alaz.hikaricom.zaxxer:HikariCPhikariruntimeLibrary, testRuntimeOnly
alaz.sqlite.jdbcorg.xerial:sqlite-jdbcsqliteruntimeLibrary, testRuntimeOnly
alaz.mysql.connectorcom.mysql:mysql-connector-jmysqlruntimeLibrary, testRuntimeOnly
alaz.mariadb.jdbcorg.mariadb.jdbc:mariadb-java-clientmariadbruntimeLibrary, testRuntimeOnly
alaz.postgresql.jdbcorg.postgresql:postgresqlpostgresqlruntimeLibrary, testRuntimeOnly
alaz.bstats.bukkitorg.bstats:bstats-bukkitbstatsarrives through alaz.taffy.metrics
alaz.faststats.bukkitdev.faststats.metrics:bukkitfaststatsarrives through alaz.taffy.metrics
alaz.comficonf.apicom.comficonf:comficonf-apicomficonfcompileOnly, testImplementation

Integration APIs

No Taffy module ships any of these. taffy-hooks compiles against ItemsAdder, Nexo, Oraxen, HeadDatabase, Vault, LuckPerms, worldguard-core, worldedit-core, worldedit-bukkit, PlaceholderAPI and MiniPlaceholders, and taffy-platform against PlaceholderAPI and MiniPlaceholders. alaz.vaultunlocked.api, alaz.playerpoints and alaz.worldguard.bukkit are in the catalog for a plugin's own code. A plugin declares one compileOnly only when its own code calls that API directly.

AccessorCoordinatesVersion key
alaz.placeholderapime.clip:placeholderapiplaceholderapi
alaz.miniplaceholders.apiio.github.miniplaceholders:miniplaceholders-apiminiplaceholders
alaz.luckperms.apinet.luckperms:apiluckperms
alaz.vault.apicom.github.MilkBowl:VaultAPIvault
alaz.vaultunlocked.apinet.milkbowl.vault:VaultUnlockedAPIvaultunlocked
alaz.playerpointsorg.black_ixx:playerpointsplayerpoints
alaz.itemsadder.apibeer.devs:itemsadder-apiitemsadder
alaz.oraxenio.th0rgal:oraxenoraxen
alaz.nexocom.nexomc:nexonexo
alaz.headdatabase.apicom.github.Arcaniax-Development:HeadDatabase-APIheaddatabase
alaz.worldguard.bukkitcom.sk89q.worldguard:worldguard-bukkitworldguard
alaz.worldguard.corecom.sk89q.worldguard:worldguard-coreworldguard
alaz.worldedit.bukkitcom.sk89q.worldedit:worldedit-bukkitworldedit
alaz.worldedit.corecom.sk89q.worldedit:worldedit-coreworldedit

taffy-hooks and taffy-platform declare each API they compile against with { isTransitive = false }, which keeps that API's own dependencies off the compile classpath. A plugin can do the same:

build.gradle.kts
dependencies {
    compileOnly(alaz.luckperms.api) { isTransitive = false }
}

Testing

AccessorCoordinatesVersion key
alaz.junit.jupiterorg.junit.jupiter:junit-jupiterjunit
alaz.junit.platform.launcherorg.junit.platform:junit-platform-launchernone
alaz.assertj.coreorg.assertj:assertj-coreassertj
alaz.mockito.coreorg.mockito:mockito-coremockito
alaz.testcontainers.junitorg.testcontainers:junit-jupitertestcontainers
alaz.testcontainers.mysqlorg.testcontainers:mysqltestcontainers
alaz.testcontainers.mariadborg.testcontainers:mariadbtestcontainers
alaz.testcontainers.postgresqlorg.testcontainers:postgresqltestcontainers

alaz.junit.platform.launcher carries no version: it takes the one the JUnit BOM sets, which alaz.junit.jupiter brings, so the two are declared together.

On this page