Gradle Plugin to automatically upgrade your Java/Kotlin project dependencies and send a GitHub pull request with the changes.
You can read this blog post for more detailed information.
upgradeDependencies
task on your CI tool (daily, weekly, monthly, as you wish)Add the following configuration to your root build.gradle
, replacing X.Y.Z by the latest version
Using the plugins DSL + Groovy:
plugins {
id "com.dipien.releaseshub.gradle.plugin" version "X.Y.Z"
}
Using the plugins DSL + Kotlin DSL:
plugins {
id("com.dipien.releaseshub.gradle.plugin").version("X.Y.Z")
}
Using legacy plugin application + Groovy:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("com.dipien:releases-hub-gradle-plugin:X.Y.Z")
}
}
apply plugin: "com.dipien.releaseshub.gradle.plugin"
Using legacy plugin application + Kotlin DSL:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("com.dipien:releases-hub-gradle-plugin:X.Y.Z")
}
}
apply(plugin = "com.dipien.releaseshub.gradle.plugin")
All the plugin configuration properties can be added using any of the following ways:
releasesHub
extension on the build.gradle. For example:
releasesHub {
gitHubRepository = "sample"
}
./gradlew listDependencies -PgitHubRepository=sample
gradle.properties
file. For example:
gitHubRepository = "sample"
ext.gitHubRepository = "sample"
Whether the plugin should automatically find the files where the dependencies are defined. This property is required. The default value is true
autoDetectDependenciesPaths = true
The plugin automatically find dependencies on the following files:
The custom paths (relative to the project root directory) for the files where the dependencies are defined. This list is used in addition to the auto detected paths (if enabled). This property is optional. For example:
dependenciesPaths = [
"dependencies.gradle.kts",
]
The dependencies to include.
You can define a groupId
to match all the artifacts for that group id, or groupId:artifactId
to match a particular artifact.
By default all the dependencies found on dependenciesClassNames
are included.
includes = ["com.groupid1", "com.groupid2:artifact1"]
The dependencies to exclude.
You can define a groupId
to match all the artifacts for that group id, or groupId:artifactId
to match a particular artifact.
By default there aren't excluded dependencies.
excludes = ["com.groupid1", "com.groupid2:artifact1"]
If you need to exclude the Gradle upgrade, use "gradle". For example:
excludes = ["gradle"]
You can define your dependencies on the libs.versions.toml
version catalog.
[libraries]
kotlin = "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.40"
kotlin-plugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.41"
buildscript {
dependencies {
classpath(libs.kotlin.plugin)
}
}
dependencies {
implementation(libs.kotlin)
}
apply plugin: "kotlin"
apply plugin: "com.dipien.releaseshub.gradle.plugin"
You can define your dependencies on the settings.gradle.kts
version catalog.
dependencyResolutionManagement {
versionCatalogs {
create("libs") {
alias("kotlin").to("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.40")
alias("kotlin-plugin").to("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.41")
}
}
}
buildscript {
dependencies {
classpath(libs.kotlin.plugin)
}
}
dependencies {
implementation(libs.kotlin)
}
apply plugin: "kotlin"
apply plugin: "com.dipien.releaseshub.gradle.plugin"
You can define your dependencies on /buildSrc/src/main/kotlin/Libs.kt
and /buildSrc/src/main/kotlin/BuildLibs.kt
classes.
object Libs {
const val KOTLIN = "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.40"
}
object BuildLibs {
const val KOTLIN_PLUGIN = "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.41"
}
buildscript {
dependencies {
classpath(BuildLibs.KOTLIN_PLUGIN)
}
}
dependencies {
implementation(Libs.KOTLIN)
}
apply plugin: "kotlin"
apply plugin: "com.dipien.releaseshub.gradle.plugin"
See the sample for more details.
To automate your dependencies upgrades, you can follow this guide: How to automate your dependencies upgrades with GitHub Actions
Validate all the dependencies. The following validations are executed:
dependenciesPaths
are sorted alphabetically by groupId:artifactId
dependenciesPaths
dependenciesPaths
but not used on the project./gradlew validateDependencies
The dependencies to exclude from the unused validation.
You can define a groupId
to match all the artifacts for that group id, or groupId:artifactId
to match a particular artifact.
By default there aren't excluded dependencies.
unusedExcludes = ["com.groupid1", "com.groupid2:artifact1"]
The file extensions of the files where the artifact's packages will we search to find unused dependendencies.
By default [".kt", ".java", ".xml"]
unusedExtensionsToSearch = [".kt", ".java"]
Print all the dependencies that will be analyzed to upgrade.
./gradlew listDependencies
Print all the dependencies that are upgradeable. A file build/releasesHub/dependencies_to_upgrade_count.txt
is generated with the count of dependencies that are upgradeable. This could be useful for metrics.
./gradlew listDependenciesToUpgrade
This task creates a Github Pull Request for each groupId that have at least one dependency to upgrade.
The following steps are executed for each groupId
:
headBranch
(headBranchPrefix
+ groupId
) (if not exists)baseBranch
to the headBranch
dependenciesClassNames
for the groupId
headBranch
headBranch
to the baseBranch
./gradlew upgradeDependencies
Whether a pull request with all the upgrades should be created or not. The default value is true
pullRequestEnabled = false
The maximum amount of pull requests to create during the task execution.
This is useful to avoid creating too much pull requests when you still have many dependencies to upgrade. The default value is 5
pullRequestsMax = 10
The list of labels to assign when creating the pull request. Optional list.
pullRequestLabels = ["dependencies"]
The user to be assigned to the pull request. Optional string.
pullRequestAssignee = "octocat"
The list of reviewers to assign when creating the pull request. Optional list.
pullRequestReviewers = ["octocat", "hubot", "other_user"]
The list of team reviewers to assign when creating the pull request. Optional list.
pullRequestTeamReviewers = ["justice-league"]
The branch's prefix where the commit will be pushed. Also, the head branch's prefix of the pull request to create. Required String (only if pullRequestEnabled
is true
). The default value is releases_hub/
.
headBranchPrefix = "branch_name_"
The pull request base branch. Optional String. The default value is master
.
baseBranch = "master"
The Git user name used by the commit command. Optional String.
gitUserName = "user"
The Git user email used by the commit command. Optional String.
gitUserEmail = "email@mail.com"
The GitHub repository where the pull request will be created. Required String (only if pullRequestEnabled
is true
).
gitHubRepository = "repo_owner/repo_name"
The GitHub repository owner where the pull request will be created. Required String (only if pullRequestEnabled
is true
& gitHubRepository
was not defined).
gitHubRepositoryOwner = "repo_owner"
The GitHub repository name where the pull request will be created. Required String (only if pullRequestEnabled
is true
& gitHubRepository
was not defined).
gitHubRepositoryName = "repo_name"
The GitHub write token needed to access the GitHub API to create the pull request. Follow these steps to create your token.
We strongly recommend to not use the releasesHub
extension for this property, to avoid exposing it on the git repository.
Required String (only if pullRequestEnabled
is true
).
gitHubWriteToken = "123"
The GitHub api host name needed to access the GitHub Enterprise. Optional String.
gitHubApiHostName = "your.githubenterprise.com"
This project uses the Semantic Versioning guidelines for transparency into our release cycle.
Sponsor this open source project to help us get the funding we need to continue working on it.