AffectedModuleDetector
AffectedModuleDetector copied to clipboard
feat: Add Git Submodule Support
Git Submodule Support
This feature automatically detects git submodules by parsing the .gitmodules file in the project root. When a submodule pointer changes (i.e., the submodule is updated to a different commit), all Gradle projects located under that submodule path are marked as affected.
How It Works
-
Auto-Detection: The plugin reads
.gitmodulesto discover all submodule paths - Change Detection: When git reports a submodule path as changed, the plugin finds all Gradle projects under that path
- Dependency Propagation: Affected submodule projects and their dependents are included in the affected set
Example
Given this project structure:
my-project/
├── .gitmodules
├── libs/
│ └── my-submodule/ # git submodule
│ ├── core/ # Gradle project :core
│ └── utils/ # Gradle project :utils
└── app/ # Gradle project :app (depends on :core)
When libs/my-submodule is updated to a new commit:
-
:coreand:utilsare marked as changed projects -
:appis marked as a dependent project (because it depends on:core)
Nested Submodules
The plugin handles nested submodules correctly. When a nested submodule changes, git reports the immediate parent submodule as changed, and the plugin finds all projects under that parent path.