/gradle-multi-git

Gradle plugin to simplify managing multiple git repositories.

Primary LanguageGroovyMIT LicenseMIT

gradle-multi-git

Gradle plugin to simplify managing multiple git repositories.

Build

./gradlew build

# publish
./gradlew publishPlugins

Usage

// file: build.gradle

plugins {
    id 'com.brightsparklabs.gradle.multi-git'
}

Configuration

Use the following configuration block to configure the plugin:

// file: build.gradle

multiGitPluginConfig {
    repositoriesDir = new File('subprojects')
    repositories = [
        'project-alpha': ['git@github.com:brightsparklabs/project-alpha.git', 4],
        'project-bravo': 'git@github.com:brightsparklabs/project-bravo.git',
    ]
}

Where:

  • repositoriesDir is the directory to checkout the git repositories to.
  • repositories is a map of repository name to repository location. Each repository will be checked out to the repositoriesDir. If you want a shallow clone of your repository, map a list to repository name containing repository location and the depth level.

Tasks

The tasks added by the plugin can be found by running:

./gradlew tasks

Methods

The following methods are added to the project:

  • gitExec(repoName, gitArgs)
    • Executes a git command on the specified git repository.
    • Arguments:
      • repoName: Name of the git repository to execute the command on.
      • gitArgs: Array of arguments to append to the 'git' command.
        • E.g. ['checkout', 'master']
  • gitExecAllRepos(gitArgs)
    • Executes a git command on all git repositories.
    • Arguments:
      • gitArgs: Array of arguments to append to the 'git' command.
        • E.g. ['checkout', 'master']

Licenses

Refer to the LICENSE file for details.