Kotlin
Completed
-
Section 1: Getting Started
-
Section 2: Core Syntax
-
Section 3: Null Safety
-
Section 4: Object-Oriented Kotlin
-
Section 5: Functional Kotlin
-
Section 6: Coroutines
-
Section 7: Collections Deep Dive
-
Section 8: Type System Deep Dive
-
Section 9: Interop and Tooling
-
Section 10: Kotlin DSLs and Patterns
-
Section 11: Testing and Quality
-
Section 12: Server-Side Kotlin
-
Section 13: Practical Projects
-
Section 14: Interview Practice
-
Section 15: More Practice Exercises
-
Section 16: More Standard Library
-
Section 17: Multiplatform Kotlin
-
Section 18: kotlin.collections In Depth
-
Section 19: kotlin.text In Depth
-
Section 20: kotlin.ranges and kotlin.sequences
-
Section 21: kotlin.io and File Handling
-
Section 22: kotlinx.coroutines Deep Dive
-
Section 23: kotlin.reflect
-
Section 24: Android Development with Kotlin Overview
-
Section 25: Kotlin Multiplatform Deep Dive
-
Section 26: Kotlin for Backend Deep Dive
-
Section 27: Kotlin Design Patterns
-
Section 28: Advanced Language Features
-
Section 29: More Practice Exercises
-
Section 30: More Interview Practice
-
Section 31: Kotlin Type System Deep Dive
-
Section 32: Kotlin Null Safety Advanced
-
Section 33: Kotlin Testing Deep Dive
-
Section 34: Kotlin Build Tooling Deep Dive
-
Section 35: Kotlin Serialization
-
Section 36: Kotlin Performance Considerations
-
Section 37: Kotlin Native Overview
-
Section 38: Kotlin for Data and Scripting
-
Section 39: More Coroutines Practice
-
Section 40: More Android-Adjacent Patterns
-
Section 41: More Practical Projects
-
Section 42: More Design and Architecture Practice
-
Section 43: Kotlin Language Evolution
-
Section 44: More Interview and Review
-
Section 45: Kotlin Delegation Patterns Deep Dive
-
Section 46: Kotlin Annotations Deep Dive
-
Section 47: Kotlin for Gradle Plugin Development
-
Section 48: Kotlin Concurrency Beyond Coroutines
-
Section 49: Kotlin Compiler Internals
-
Section 50: Real-World Kotlin Case Studies
-
Section 51: Final Practice Projects
-
Section 52: Kotlin for Server-Side Reactive Programming
-
Section 53: More Practice and Drills
-
Section 54: Kotlin Security Practices
220: Publishing Gradle Plugins to the Portal
How do I actually tell the Portal what my plugin is called and what it does?
You can't just upload a JAR and hope for the best; the Gradle Plugin Portal needs specific metadata to make your plugin discoverable. This is handled by the gradle-plugin-publish plugin. I usually suggest adding this to your build script alongside maven-publish.
You'll need a gradlePlugin block in your build.gradle.kts. This is where you map your plugin ID—the string people actually put in their plugins {} block—to the implementation class. For our example, let's say we've built a license-checker plugin that ensures every file has a corporate header.
plugins {
`kotlin-dsl`
`maven-publish`
id("com.gradle.plugin-publish") version "1.2.1"
}
gradlePlugin {
plugins {
create("licenseCheckerPlugin") {
id = "com.yourname.license-checker"
implementationClass = "com.yourname.license.LicenseCheckerPlugin"
displayName = "Corporate License Header Checker"
description = "Scans your src directory to ensure all Kotlin files have the standard legal header."
tags.add("quality")
tags.add("compliance")
}
}
}
Notice the id. That's the "public face" of your plugin. If you get this wrong, no one can use your plugin without manually specifying the coordinates, which is a pain they'll probably avoid.
Where do I put my API keys so I don't accidentally leak them on GitHub?
This is a classic mistake. Never, ever hardcode your Gradle Portal keys in the build script. I've seen too many engineers have to rotate their keys because they pushed a "quick fix" to a public repo. Instead, use your global gradle.properties file located in your user home directory (~/.gradle/gradle.properties).
The gradle-plugin-publish plugin looks for specific property names. Create these entries in that file:
gradlePluginsPublishingKey=your_api_key_here
gradlePluginsPublishingSecret=your_api_secret_here
By keeping these in the home directory, they stay local to your machine. When you move to a CI/CD pipeline like GitHub Actions, you'll inject these as environment variables. Gradle is smart enough to pick up ORG_GRADLE_PROJECT_gradlePluginsPublishingKey as an override.
Do I just run a 'publish' task, or is there more to it?
It's a bit of both. Because the Plugin Portal is essentially a proxy for a Maven repository, you first need a publication defined. The kotlin-dsl plugin usually handles the heavy lifting of creating the Maven publication for you, but you still need to trigger the specific upload task.
To push everything to the portal, you'll run:
./gradlew publishAllPublicationsToGradlePluginPortal
I'll be honest: the first time you run this, it'll probably fail. Usually, it's because of a missing pom.xml detail or a version conflict. If it does, check the logs for "400 Bad Request." That's usually a sign that your gradlePlugin block is missing a required field or your version string doesn't follow semantic versioning. I always recommend running publishToMavenLocal first. If it works on your machine's local cache, you know the packaging is fine and the issue is likely with your Portal credentials or metadata.
📋 Practical Task
Configuring the License-Checker Metadata and Local Publication
You have been given a skeleton project for the license-checker plugin. Your goal is to make it "publish-ready" without actually pushing it to the live portal yet.
- Add the
com.gradle.plugin-publishplugin to thepluginsblock. - Configure the
gradlePluginblock so that the plugin ID iscom.software.license-checkerand the implementation class points tocom.software.license.LicenseCheckerPlugin. - Add at least two descriptive tags (e.g., "legal", "linting") to the metadata.
- Run the
publishToMavenLocaltask and verify that the artifact appears in your~/.m2/repositoryfolder.
There are no comments for now.