Giter Site home page Giter Site logo

gradle / wrapper-upgrade-gradle-plugin Goto Github PK

View Code? Open in Web Editor NEW
43.0 14.0 17.0 912 KB

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

License: Apache License 2.0

Java 56.39% Groovy 43.61%
gradle maven wrapper gradle-bt gradle-bt-core-runtime

wrapper-upgrade-gradle-plugin's Introduction

Wrapper Upgrade Gradle Plugin

Verify Build Plugin Portal Revved up by Gradle Enterprise

The Wrapper Upgrade Gradle Plugin creates tasks to upgrade the Gradle Wrapper for target projects hosted on GitHub.

Usage

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

Kotlin DSL
plugins {
    id("base")
    id("org.gradle.wrapper-upgrade") version "0.11.1"
}

wrapperUpgrade {
    gradle {
        register("some-gradle-project") {
            repo.set("my-org/some-gradle-project")
            baseBranch.set("release")
        }
        register("some-samples-gradle-project") {
            repo.set("my-org/some-samples-gradle-project")
            dir.set("samples")
        }
    }

    maven {
        register("some-maven-project") {
            repo.set("my-org/some-maven-project")
            baseBranch.set("release")
        }
        register("some-samples-maven-project") {
            repo.set("my-org/some-samples-maven-project")
            baseBranch.set("samples")
        }
    }
}
Groovy DSL
plugins {
    id 'base'
    id 'org.gradle.wrapper-upgrade' version '0.11.4'
}

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 personal access token (PAT), passed with WRAPPER_UPGRADE_GIT_TOKEN environment variable. This token is used to get the existing PRs on the repo and create one if needed, hence it requires:
      • the repo scope for a classic PAT
      • read-write permissions for "Pull requests" on the relevant repos for a fine-grained PAT

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.

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.