Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ affectedModuleDetector {
logFolder = "${project.rootDir}/output"
compareFrom = "PreviousCommit" //default is PreviousCommit
excludedModules = [
"sample-util"
"sample-util", ":(app|library):.+"
]
includeUncommitted = true
top = "HEAD"
Expand All @@ -116,7 +116,7 @@ affectedModuleDetector {
- SpecifiedBranchCommitMergeBase: compare against the nearest ancestors with `$specifiedBranch` using `git merge base` approach.

**Note:** specify the branch to compare changes against using the `specifiedBranch` configuration before the `compareFrom` configuration
- `excludedModules`: A list of modules that will be excluded from the build process
- `excludedModules`: A list of modules that will be excluded from the build process, can be the name of a module, or a regex against the module gradle path
- `includeUncommitted`: If uncommitted files should be considered affected
- `top`: The top of the git log to use. Must be used in combination with configuration `includeUncommitted = false`
- `customTasks`: set of [CustomTask](https://github.com/dropbox/AffectedModuleDetector/blob/main/affectedmoduledetector/src/main/kotlin/com/dropbox/affectedmoduledetector/AffectedModuleConfiguration.kt)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,9 @@ class AffectedModuleDetectorImpl constructor(
val isRootProject = project.isRoot
val isProjectAffected = affectedProjects.contains(project)
val isProjectProvided = isProjectProvided2(project)
val isNotModuleExcluded = !config.excludedModules.contains(project.name)
val isModuleExcludedByName = config.excludedModules.contains(project.name)
val isModuleExcludedByRegex = config.excludedModules.any { project.path.matches(it.toRegex()) }
val isNotModuleExcluded = !(isModuleExcludedByName || isModuleExcludedByRegex)

val shouldInclude = (isRootProject || (isProjectAffected && isProjectProvided)) && isNotModuleExcluded
logger?.info("checking whether I should include ${project.path} and my answer is $shouldInclude")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1260,6 +1260,34 @@ class AffectedModuleDetectorImplTest {
Truth.assertThat(detector.shouldInclude(p5)).isTrue()
}

@Test
fun `GIVEN regex is in excludedModules configuration WHEN shouldInclude THEN excluded module false AND dependent modules true`() {
affectedModuleConfiguration = affectedModuleConfiguration.also {
it.excludedModules = setOf(":p1:p3:[a-zA-Z0-9:]+")
}
val detector = AffectedModuleDetectorImpl(
rootProject = root,
logger = logger,
ignoreUnknownProjects = false,
projectSubset = ProjectSubset.ALL_AFFECTED_PROJECTS,
modules = null,
injectedGitClient = MockGitClient(
changedFiles = listOf(
convertToFilePath("p1/p3", "foo.java"),
convertToFilePath("p1/p3/p4", "foo.java"),
convertToFilePath("p2/p5", "foo.java"),
convertToFilePath("p1/p3/p6", "foo.java")
),
tmpFolder = tmpFolder.root
),
config = affectedModuleConfiguration
)
Truth.assertThat(detector.shouldInclude(p3)).isTrue()
Truth.assertThat(detector.shouldInclude(p4)).isFalse()
Truth.assertThat(detector.shouldInclude(p5)).isTrue()
Truth.assertThat(detector.shouldInclude(p6)).isFalse()
}

@Test
fun `GIVEN a file that effects all changes has a change WHEN projectSubset is CHANGED_PROJECTS THEN all modules should be in this`() {
val changedFile = convertToFilePath("android", "gradle", "test.java")
Expand Down