Skip to content

Team Setup

Geert Bevin edited this page Feb 1, 2024 · 3 revisions

Since bld doesn't automatically resolve and download all dependencies for every command, it's possible for the jar files in your lib directories to grow stale if you forget to run bld download purge when someone else changes the build file.

Enable autoDownloadPurge

If you set autoDownloadPurge to true in your project, bld will automatically create a fingerprint of your dependency configuration. Whenever a change is detected to your dependencies, bld will run the download and purge commands before any other commands, then update the fingerprint.

This is a convenient way to automatically keep all your libraries in sync with your project dependencies, but any jar files that you put in your lib directories will be forcibly removed and each change to your dependencies (even repository changes), will trigger a download at the next build.

Create a post-merge git hook

Another solution is to use git hooks to automatically run this command upon update.

Below is how I've set this up for the projects with my team.

The post-merge git stage will always be triggered after you pulled in changes, even if there's nothing to merge. Usually you'd create the post-merge file in your .git/hooks directory, but that is only local and will not be shared with your team members.

I create the file in hooks/post-merge, this is what it looks like:

#!/bin/sh
cd "$(git rev-parse --show-toplevel)"
./bld download purge
exit $?

Activate the hook for everyone

Since bld can run any Java logic, you can use it to ensure that a symbolic link to the hooks/post-merge file is created in a user's local .git directory.

For instance:

public class MyappBuild extends WebProject {
    public MyappBuild() {
        // ...
        ensurePostMergeHook();
    }

    void ensurePostMergeHook() {
        try {
            var link = Path.of(workDirectory().getPath(), ".git", "hooks", "post-merge");
            var target = Path.of(workDirectory().getPath(), "hooks", "post-merge");
            if (!Files.exists(link)) {
                Files.createSymbolicLink(link, target);
            }
        } catch (IOException e) {
            System.err.println("ERROR: Unable to create the symbolic link for a Git post-merge hook.\n" + ExceptionUtils.getExceptionStackTrace(e));
        }
    }

    public static void main(String[] args) {
        new MyappBuild().start(args);
    }
}

That's it! The next time your team members perform the project's build, the symbolic link will be created and from then onwards, the dependency jar files will always be kept in sync.


Next learn more about Sensitive and Common Data

Clone this wiki locally