Article 1: Create a Gradle Plugin from A to Z with the gradle init command
Published on 23 September 2025
Introduction
Starting a new Gradle plugin project can seem intimidating. Fortunately, Gradle provides a powerful interactive assistant, the task`init`, which generates a complete, clean, and ready-to-use project structure. This guide will show you how to use this tool to create a healthy plugin base, explain its structure, and show you how to run the initial build tasks.
Step 1: Launch the project assistant
The command`gradle init`is the starting point. It launches a command-line assistant that asks you a series of questions to configure the project.
Open your terminal in an empty folder and run:
gradle init
The assistant will guide you. Here are the choices to make for a Gradle plugin written in Kotlin:
-
Select type of project to generate:Choose`Gradle plugin`.
-
Select implementation language:Choose`Kotlin`.
-
Select build script DSL:Choose`Kotlin`.
-
Project name:Enter a name for your project (ex:`site-baker`).
-
Plugin id:Give a unique identifier to your plugin (e.g:`com.cheroliv.site-baker`).
-
Plugin class:Spécifiez le nom de la classe d’implémentation (ex:`com.cheroliv.SiteBakerPlugin`).
Once finished, Gradle generates a complete file tree.
@startuml start :Lancer `gradle init`; :Choisir "Gradle plugin"; :Choisir "Kotlin" (langage); :Choisir "Kotlin" (DSL); :Saisir nom, ID, et classe; :Projet généré; stop @enduml
Step 2: Understanding the generated structure
The assistant creates a multi-module project structure, separating the root project from the plugin source code itself.
.
├── gradle/
│ └── wrapper/
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── plugin/
│ ├── build.gradle.kts
│ └── src/
│ ├── main/
│ │ └── kotlin/
│ │ └── com/cheroliv/SiteBakerPlugin.kt
│ ├── test/
│ │ └── kotlin/
│ │ └── com/cheroliv/SiteBakerPluginTest.kt
│ └── functionalTest/
│ └── kotlin/
│ └── com/cheroliv/SiteBakerPluginFunctionalTest.kt
└── settings.gradle.kts
key files and folders
-
settings.gradle.kts`This file at the root defines the modules included in the build. Here, it includes the sub-project`plugin.
[source,kotlin] (No text provided to translate) rootProject.name = "site-baker include("plugin") ----