Introducing pluginx-resolver
: Auto Resolve and Inject Gradle Plugin Classpath with Custom Repositories
Hi Gradle community!
I’m excited to share a new open-source Gradle plugin I created called pluginx-resolver
. It aims to simplify how you manage plugin dependencies and repositories in Gradle builds, especially when using private or custom Maven repositories.
The Problem
Gradle’s plugin system resolves plugins through the Plugin Portal by default. However, many enterprises or projects host plugins in private Maven repositories. In such cases, users usually need to:
- Manually declare plugin classpath dependencies inside
buildscript.classpath
- Configure private Maven repositories separately in multiple places (
pluginManagement.repositories
,buildscript.repositories
) - Keep plugin coordinates and classpath dependencies in sync, which can be error-prone
Example of duplicated config:
pluginManagement {
repositories {
gradlePluginPortal()
maven { url = uri("https://my.company.repo/releases") }
}
resolutionStrategy {
eachPlugin {
if (requested.id.id == "com.company.plugin") {
useModule("com.company:internal-plugin:${requested.version}")
}
}
}
}
buildscript {
dependencies {
classpath("com.company:internal-plugin:1.2.3")
}
}
The Solution: pluginx-resolver
pluginx-resolver
solves this by:
- Automatically resolving plugin artifacts declared in
pluginManagement.resolutionStrategy
- Fetching plugin POM metadata and extracting their dependencies
- Injecting required classpath dependencies into the build without manual duplication
- Reading Maven repository definitions (including credentials) from
gradle.properties
and injecting them intopluginManagement.repositories
automatically (optional, enabled by default)
How to Use
Add to your settings.gradle.kts
:
plugins {
id("io.github.neallon.pluginx.resolver") version "1.1.0"
}
pluginManagement {
repositories {
gradlePluginPortal()
mavenCentral()
}
resolutionStrategy {
eachPlugin {
if (requested.id.id == "com.example.plugin") {
useModule("com.example:my-plugin:${requested.version}")
}
}
}
}
pluginxResolver {
autoInjectRepositories = false // Optional; default is true
}
Define your private repositories in gradle.properties
:
hfx.myRepo.repo.url=https://my.company.repo/maven
hfx.myRepo.user=admin
hfx.myRepo.password=supersecret
Benefits
- Eliminate manual duplication of plugin classpath dependencies
- Centralize repository configuration via
gradle.properties
- Support private Maven repos with credentials
- Compatible with Kotlin & Groovy DSLs
- Works seamlessly with Gradle 7.5+
Resources
- Plugin Portal: Gradle - Plugin: io.github.neallon.pluginx.resolver
- GitHub Repo: GitHub - neallon/pluginx-resolver: Automatically resolves and injects plugin classpath dependencies based on pluginManagement resolutionStrategy
Feedback & Contribution
The plugin is open source and actively maintained. I welcome bug reports, feature requests, and contributions.
If you deal with enterprise or complex Gradle setups, give it a try and share your experience!
Thanks for reading!
Neallon
GitHub: neallon