Skip to content

Latest commit

 

History

16 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gradle Toolbox (gt)

A toolkit for people developing Gradle itself. It manages a single bare clone of the Gradle repository and gives every branch its own git worktree, so you can switch between branches, PRs, and built distributions without stashing or rebuilding the world.

This is the successor of genv, extending the environment idea with a worktree-based workflow.

With gt, you can:

  • Keep one bare repository and check out each branch into its own worktree
  • Fetch GitHub PRs straight into worktrees (gt pull 12345)
  • Build a Gradle distribution from any worktree and alias gradle to it (gt install + gt use)
  • Reclaim disk space and prune merged-PR branches (gt cleanup)

How to install?

The tool builds upon fish and fisher.

fisher install hegyibalint/gradle-toolbox

Then initialize it from a remote URL (bare clone) or an existing local clone:

gt init https://github.com/gradle/gradle.git

Everything lives under $XDG_DATA_HOME/gradle-toolbox (repo, worktrees, shared resources).

How to use?

gt create my-feature -o -n   # branch off master, open in IDEA, cd into it
gt pull 30123 -o             # fetch PR #30123 into a pull/30123 worktree
gt install my-feature        # build a distribution (--all for sources)
gt use my-feature            # alias `gradle` to that distribution
gt cleanup cache --dry-run   # see what disk space can be reclaimed

Command reference

Every worktree lives under the data directory at worktrees/<branch>, so the branch name doubles as the worktree path. Whenever a worktree is created, shared resources from the data directory's resources/ folder (e.g., agent docs, .claude config) are copied into it.

Initialization

gt init <repository-url|repository-path>

One-time setup, pointing the toolbox at the Gradle repository. Given a URL, clones a bare copy for the toolbox to manage; given a path to an existing local clone, uses that in place. All subsequent commands work against this repository.

Repository-level operations

gt update

Runs git fetch --all on the repository.

gt git <args...> (alias: gtg)

Runs an arbitrary git command against the repository, from anywhere. Useful since the bare repo has no working directory to cd into. The gtg shorthand saves typing gt git every time (e.g., gtg branch -a, gtg log master).

Worktree operations

gt create <branch> [--open/-o] [--navigate/-n]

Creates a new branch off master with its own worktree. --open opens it in IntelliJ IDEA, --navigate cd's into it.

gt checkout <branch> [--open/-o]

Fetches, then checks out an existing branch into a worktree.

gt pull <pr-number> [--open/-o]

Fetches a GitHub PR head into a local pull/<number> branch and creates a worktree for it. Designed for external contributor PRs, where the branch only exists on a fork; for PRs from internal branches, use gt checkout <branch> instead.

gt delete [--force/-f] <branch>...

Removes the worktree(s) and deletes the branch(es). Refuses to delete if the worktree has uncommitted changes or the branch is not fully merged; --force deletes anyway, losing that work.

gt move <old-branch> <new-branch>

Renames a branch and moves its worktree accordingly (git worktree move + git branch -m).

gt cleanup cache [branch...] [--dry-run]

Reclaims disk space by deleting every git-ignored file (build/, .gradle/, .idea/, ...) from the given worktrees, or all of them. Tracked and untracked-but-not-ignored files are kept, so uncommitted work is never touched; nested git repositories are skipped. Prints a per-worktree size report and re-provisions shared resources afterwards. --dry-run only reports what would be freed.

gt cleanup pr [--dry-run]

Cross-checks every worktree branch against GitHub (via gh) and offers to delete branches whose PRs are all closed or merged. Branches with an open PR, no PR, or named release are kept. Asks for confirmation before deleting.

Development

gt open <branch>

Opens the branch's worktree in IntelliJ IDEA.

gt cd <branch> / gt pwd <branch>

Changes into, or prints, the branch's worktree path. gt pwd composes well with other tools (e.g., code (gt pwd my-feature)).

gt install [--all] <branch>

Builds a Gradle distribution from the branch into <worktree>/build/dist (./gradlew install). --all builds the full distribution including sources (installAll).

gt use <branch>

Aliases gradle in the current shell to the branch's installed distribution, printing which branch it runs from on each invocation. Offers to install first if no distribution exists yet.

gt doctor

Re-provisions the shared resources into every worktree. Idempotent: files are only copied over, never removed.

About

Simple toolkit to be more productive at developing Gradle

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages