AffectedModuleDetector
AffectedModuleDetector copied to clipboard
`excludeModules` does not work for modules without the plugin applied
Version: 0.3.0
In version 0.2.2 the same project setup works fine without any changes, bumping to 0.3.0 makes the task failing.
Context
We have a multi-module project with some service modules which are not supposed to be included in AMD scope. When AMD is applied for the root project it seems that it assumes that all modules are in the scope.
When we define some of modules we do not want to be evaluated by AMD by using excludeModules
, we assume
that they will not be taken into account by AMD. Which is not true.
The issue is that even when we add such modules in exclude:
affectedModuleDetector {
...
excludedModules = setOf("service-module")
...
}
it is still evaluated by AMD when we run ./gradlew runAffectedUnitTests -Paffected_module_detector.enable
.
And it leads to such error:
> Could not create task ':runAffectedUnitTests'.
> Extension with name 'AffectedModuleDetectorPlugin' does not exist. Currently registered extension names: [..., affectedModuleDetector, ...]
Caused by: org.gradle.api.UnknownDomainObjectException: Extension with name 'AffectedModuleDetectorPlugin' does not exist. Currently registered extension names: [..., affectedModuleDetector, ...]
at org.gradle.internal.extensibility.ExtensionsStorage.unknownExtensionException(ExtensionsStorage.java:144)
at org.gradle.internal.extensibility.ExtensionsStorage.getByName(ExtensionsStorage.java:123)
at org.gradle.internal.extensibility.DefaultConvention.getByName(DefaultConvention.java:190)
at com.dropbox.affectedmoduledetector.AffectedModuleDetector$Companion.getInstance(AffectedModuleDetector.kt:196)
at com.dropbox.affectedmoduledetector.AffectedModuleDetector$Companion.getOrThrow(AffectedModuleDetector.kt:201)
at com.dropbox.affectedmoduledetector.AffectedModuleDetector$Companion.isProjectAffected(AffectedModuleDetector.kt:248)
at com.dropbox.affectedmoduledetector.AffectedModuleDetectorPlugin.withPlugin$lambda-14(AffectedModuleDetectorPlugin.kt:178)
It happens because AffectedModuleDetector.isProjectAffected(project)
looks like this:
@JvmStatic
@Throws(GradleException::class)
fun isProjectAffected(project: Project): Boolean {
return getOrThrow(
project
).shouldInclude(project)
}
The issue as I see is that shouldInclude()
is evaluated after getOrThrow()
which assumes all modules should have the AMD applied even when it is excluded in the config.
Just wondering if it is an expected behavior, because from plugin user perspective it is probably not when such module added explicitly to excludeModules