Skip to content

Gradle plugin that detects and updates Gradle and Maven wrappers to the latest Gradle and Maven version.

License

Notifications You must be signed in to change notification settings

clayburn/wrapper-upgrade-gradle-plugin

 
 

Repository files navigation

This repository is maintained by the Gradle Enterprise Solutions team, as one of several publicly available repositories:

Wrapper Upgrade Gradle Plugin

Verify Build Plugin Portal Revved up by Gradle Enterprise

The Wrapper Upgrade Gradle Plugin create tasks to upgrade Gradle wrappers for target projects hosted on Github.

Usage

Apply the plugin to a dedicated project and configure which project needs to be upgraded. Example:

plugins {
    id 'base'
    id 'org.gradle.wrapper-upgrade' version '0.11.1'
}

wrapperUpgrade {
    gradle {
        'some-gradle-project' {
            repo = 'my-org/some-gradle-project'
            baseBranch = 'release'
        }
        'some-samples-gradle-project' {
            repo = 'my-org/some-samples-gradle-project'
            dir = 'samples'
        }
    }

    maven {
        'some-maven-project' {
            repo = 'my-org/some-maven-project'
            baseBranch = 'release'
        }
        'some-samples-maven-project' {
            repo = 'my-org/some-samples-maven-project'
            dir = 'samples'
        }
    }
}

This will create one task per configured project and 2 aggregating tasks: upgradeGradleWrapperAll and upgradeMavenWrapperAll that will run all the specific tasks.

Running ./gradlew upgradeGradleWrapperXXX will:

  • clone the project XXX in build/git-clones
  • run in the cloned project ./gradlew wrapper --gradle-version=<latest_gradle_version>
  • run a second time ./gradlew wrapper --gradle-version=<latest_gradle_version>
  • If changes occurred
    • create a specific branch
    • commit and push the branch
    • create a pull request on Github, it requires a Github access token, passed with WRAPPER_UPGRADE_GIT_TOKEN environment variable.

Note that a check is done first to make sure the branch does not exist yet. That way you can run upgradeGradleWrapperAll and upgradeMavenWrapperAll periodically with a cron, CI job... a bit like dependabot does for upgrading libs.

Running upgradeMavenWrapperXXX will do the same, executing ./mvnw wrapper:wrapper -Dmaven=<latest_maven_version> instead.

Task configuration

wrapperUpgrade {
    <gradle|maven> {
        name {
            repo = ...
            baseBranch = ...
            dir = ...
            options {
                gitCommitExtraArgs = [...]
                allowPreRelease = [...]
            }
        }
    }
}
Field description
name A name identifying the upgrade, it can be different from the project name, for example when you need to upgrade multiple gradle projects in the same git project
repo The Github repository to clone, format 'organization/project`
dir The directory inside the project base directory to run the gradle or maven upgrade in
baseBranch The git branch to checkout and that the pull request will target
options.gitCommitExtraArgs List of additional git commit arguments
options.allowPreRelease Boolean: true will get the latest Maven/Gradle version even if it's a pre-release. Default is false.

License

The Wrapper Upgrade Gradle plugin is open-source software released under the Apache 2.0 License.

About

Gradle plugin that detects and updates Gradle and Maven wrappers to the latest Gradle and Maven version.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 60.3%
  • Groovy 39.7%