Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

excludeModules does not work for modules without the plugin applied #246

Open
silin opened this issue Mar 14, 2024 · 0 comments
Open

excludeModules does not work for modules without the plugin applied #246

silin opened this issue Mar 14, 2024 · 0 comments

Comments

@silin
Copy link

silin commented Mar 14, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant