### Multi-Trunk Repository Structure Example Source: https://trunkbaseddevelopment.com/alternative-branching-models This example illustrates a repository structure with multiple top-level modules, each having its own branches and trunk. This model can become unwieldy, especially with lock-step releases across all trunks. ```text root/ module_one/ branches/ rel_1.0.0/ rel_1.1.0/ trunk/ build_file.xml src/ # prod source directory tree # test source directory tree module_two/ branches/ rel_1.0.0/ rel_1.1.0/ trunk/ build_file.xml src/ # prod source directory tree # test source directory tree module_three/ branches/ rel_1.0.0/ rel_1.1.0/ trunk/ build_file.xml src/ # prod source directory tree # test source directory tree ``` -------------------------------- ### Git Sparse Checkout Example Source: https://trunkbaseddevelopment.com/expanding-contracting-monorepos Demonstrates the directory structure resulting from Git's sparse checkout feature with different parameters. This shows how a working copy can be dynamically expanded or contracted based on the specified modules. ```text root/ java/ BUILD com/ BUILD google/ BUILD myteamsapplication/ BUILD MyTeamsApplication.java // and hundreds of other packages and source files theirapplication/ BUILD TheirApplication.java // and hundreds of other packages and source files theormwebothdependon/ BUILD TheORMweBothDependOn.java // and hundreds of other packages and source files java_test/ BUILD com/ BUILD google/ BUILD myteamsapplication/ BUILD MyTeamsApplicationTest.java // and hundreds of other packages and source files theirapplication/ BUILD TheirApplicationTest.java // and hundreds of other packages and source files theormwebothdependon/ BUILD TheORMweBothDependOnTest.java // and hundreds of other packages and source files ``` ```text root/ java/ BUILD com/ BUILD google/ BUILD myteamsapplication/ BUILD MyTeamsApplication.java // and hundreds of other packages and source files theormwebothdependon/ BUILD TheORMweBothDependOn.java // and hundreds of other packages and source files java_test/ BUILD com/ BUILD google/ BUILD myteamsapplication/ BUILD MyTeamsApplicationTest.java // and hundreds of other packages and source files theormwebothdependon/ BUILD TheORMweBothDependOnTest.java // and hundreds of other packages and source files ``` ```text root/ java/ BUILD com/ BUILD google/ BUILD theormwebothdependon/ BUILD TheORMweBothDependOn.java // and hundreds of other packages and source files java_test/ BUILD com/ BUILD google/ BUILD theormwebothdependon/ BUILD TheORMweBothDependOnTest.java // and hundreds of other packages and source files ``` -------------------------------- ### Single Trunk with Multiple Modules Repository Structure Example Source: https://trunkbaseddevelopment.com/alternative-branching-models This alternative structure presents a single trunk with multiple modules nested within it. This approach, combined with a recursive or directed graph build system (like Buck or Bazel), simplifies release management and build processes compared to the multi-trunk model. ```text root/ branches/ rel_1.0.0/ rel_1.1.0/ trunk/ module_one/ build_file.xml src/ # prod source directory tree # test source directory tree module_two/ build_file.xml src/ # prod source directory tree # test source directory tree module_three/ build_file.xml src/ # prod source directory tree # test source directory tree ``` -------------------------------- ### Java: Dependency Injection for Feature Flags Source: https://trunkbaseddevelopment.com/feature-flags This Java code snippet illustrates how to configure feature flags using dependency injection. It suggests retrieving the class name for a feature from a configuration object and then using a container to instantiate and manage that component. This approach promotes cleaner code by avoiding explicit if/else checks for feature activation. ```Java bootContainer.addComponent(classFromName(config.get("purchasingCompleting"))); ```