Skip to content

sureshg/build-commons

Repository files navigation

🐘 Common Build Plugins

GitHub Workflow Status Maven Central Version OpenJDK Version Kotlin release

Gradle convention plugins that simplify bootstrapping Kotlin/Java projects targeting JVM, Multiplatform (Native/JS/Wasm/Wasi), and GraalVM native-image. Focus on writing code — these plugins handle the rest:

  • Publishing — Maven Central, GHCR, container images (Jib), artifact signing
  • Build & Toolchain — Java/Kotlin toolchain, target platforms (JVM, JS, WASM, WASI, Native), build config generation
  • Coverage, Formatting & ABI — Code coverage (JVM & KMP), code formatting, binary compatibility (ABI) validation, deprecated API scanning (jdeprscan)
  • Versioning — SemVer based on Git tags
  • Testing & Docs — Testing, reports, JavaDoc, Dokka
  • Benchmarking — JMH benchmarking via kotlinx-benchmark
  • Processors — KSP & annotation processors, GraalVM native-image, executable JARs
  • Version Catalog — Controls artifact versions and build configurations
  • Auto-configured Dependencieskotlinx-datetime, kotlinx-coroutines, ktor-client, kotlinx-serialization, kotlinx-io, logging
  • Auto-configured Compiler Pluginsredacted, kopy, power-assert, atomicfu, dataframe

🔌 Published Plugins

  • dev.suresh.plugin.root — Root project configuration and shared settings
  • dev.suresh.plugin.common — Common conventions for all subprojects
  • dev.suresh.plugin.kotlin.jvm — Kotlin JVM project setup
  • dev.suresh.plugin.kotlin.mpp — Kotlin Multiplatform project setup
  • dev.suresh.plugin.graalvm — GraalVM native-image support
  • dev.suresh.plugin.kotlin.docs — Documentation generation (Dokka)
  • dev.suresh.plugin.kotlin.benchmark — JMH benchmarking support
  • dev.suresh.plugin.publishing — Maven Central publishing and signing
  • dev.suresh.plugin.repos — Repository configuration (settings plugin)
  • dev.suresh.plugin.catalog — Version catalog management

🚀 How to Use

1. Configure settings.gradle.kts
pluginManagement {
    resolutionStrategy {
        eachPlugin {
            if (requested.id.id.startsWith("dev.suresh.plugin")) {
                useVersion("<plugin version>")
            }
        }
    }

    repositories {
        gradlePluginPortal()
        mavenCentral()
    }
}

plugins { id("dev.suresh.plugin.repos") }
2. Apply plugins in build.gradle.kts
// Kotlin JVM
plugins {
    id("dev.suresh.plugin.root")
    id("dev.suresh.plugin.kotlin.jvm")
    id("dev.suresh.plugin.publishing")
    // id("dev.suresh.plugin.graalvm")
    application
}

// Kotlin Multiplatform
plugins {
    id("dev.suresh.plugin.root")
    id("dev.suresh.plugin.kotlin.mpp")
    id("dev.suresh.plugin.publishing")
}

kotlin {
    jvmTarget(project)
    jsTarget(project)
    wasmJsTarget(project)
    wasmWasiTarget(project)
    nativeTargets(project) {}
}
3. Set up the version catalog

Copy gradle/libs.versions.toml and update the project-related metadata (group, app-mainclass, etc.).

⚠️ Don't change the existing version names in the catalog as they are referenced by the plugins.

🏗️ Build & Test

Important

Requires Java 25+ (sdk i java 25.0.1-zulu) and the latest IntelliJ IDEA.

# Build all modules
$ ./gradlew build

# Update dependencies
$ junie --guidelines-filename=.aiassistant/rules/version-updates.md "Update the dependency versions"
# OR
$ ./gradlew dependencyUpdates --no-parallel

A separate sandbox project is available for testing with the plugins applied:

# Publish plugins to Maven local
$ ./gradlew publishToMavenLocal

# Build the sandbox app
$ ./gradlew -p sandbox :build
$ sandbox/build/libs/sandbox

# Show task graph
$ ./gradlew build --task-graph

# Run other plugin tasks
$ ./gradlew -p sandbox :dependencyUpdates --no-parallel

# See the plugin classpath
$ ./gradlew -p sandbox :buildEnvironment | grep -i "dev.suresh"

📦 Publishing a Release

Push a new tag to trigger the release workflow and publish to Maven Central. The next version is based on the semantic version scope (major, minor, patch).

$ ./gradlew pushSemverTag "-Psemver.scope=patch"

# See the current version
# $ ./gradlew v

# Print the new version
# $ ./gradlew printSemver "-Psemver.scope=patch"

# For a specific version
# $ git tag -am "v1.2.3 release" v1.2.3
# $ git push origin --tags

Verifying Artifacts

The published artifacts are signed using this key. The best way to verify artifacts is automatically with Gradle.

Misc

Maven Central Publishing

# Publish to local maven repository
$ rm -rf ~/.m2/repository/dev/suresh
$ ./gradlew publishToMavenLocal
$ tree ~/.m2/repository/dev/suresh

# Publish the plugins to maven central
$ ./gradlew publishToMavenCentral

Misc

# Update the Gradle Daemon JVM
$ ./gradlew updateDaemonJvm --jvm-version=25 --jvm-vendor=adoptium

📚 References

About

✨ Gradle plugins and catalog for Kotlin JVM, GraalVM and Multiplatform (Native/JS/WASM/WASI) development!

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages