Skip to content

Fresh dist worktree

Roger Sheen edited this page Mar 21, 2022 · 7 revisions

Use a fresh worktree for distribution builds

As of Git 2.5, it's no longer necessary to create a fresh clone to test distribution builds.

Instead, you can use the new worktree command to create a separate working copy that shares the main .git metadata folder per https://git-scm.com/docs/git-worktree.

Add a new worktree

From your main clone of the DITA-OT core repository, run the following command to create a new branch named test/dist-build from the tip of the develop branch and check that out to a new worktree in a sibling directory named dita-ot.dist.worktree:

git worktree add -b test/dist-build ../dita-ot.dist.worktree develop

Then initialize submodules, and run both Gradle builds:

cd ../dita-ot.dist.worktree/ &&\
git submodule update --init --recursive &&\
./gradlew &&\
./gradlew dist

Review distribution build results

When the command sequence above completes, you'll find the results in the
dita-ot.dist.worktree/ folder under build/tmp/dist/.

The contents of this folder are also compressed to a zip archive
under dita-ot.dist.worktree/build/distributions/.

Clean up afterwards

When you're done testing:

  1. Switch back to your main clone
  2. Remove the worktree, passing the --force option (required for submodules)
  3. Delete the extra branch
cd - &&\
git worktree remove ../dita-ot.dist.worktree/ --force &&\
git branch --delete test/dist-build
Clone this wiki locally