Skip to content

AMD can't propely map changed files and set affected project state to true. #292

@AShunevych

Description

@AShunevych

Hi, I have an issue with this lib. Version used - 0.5.0

On file change, and running the gradle command, lib can't properly map the changed files and adds them as the unknownFiles

Project has next config in build.gradle.kts :

affectedModuleDetector {
    baseDir = "${project.rootDir}"
    logFilename = "output.log"
    logFolder = "${project.rootDir}/output"
    specifiedBranch = "origin/master"
    compareFrom = "SpecifiedBranchCommitMergeBase"    
    ignoredFiles = [
        ".*\\.md", ".*\\.txt", ".*README"
    ]
    buildAllWhenNoProjectsChanged = true // default is true
    includeUncommitted = true
    customTasks = setOf(
        AffectedModuleConfiguration.CustomTask(
            "logAffectedProjectsChanges",
            "logAffectedChanges",
            "Quick assemble for affected projectes"
        )
    )
}

Running git diff origin/master --name-only displays that changes in files to origin/master branch are reflected correctly.
Task logAffectedChanges - is just for simply print message into log to make quick check on CI.

On running task logAffectedProjectsChanges -Paffected_module_detector.enable it does generate log file which shows all modules and their dependencies correctly
I can't provide all the log file but can provide snippets;


[INFO] [amd] Using real detector with ALL_AFFECTED_PROJECTS
[INFO] [amd] Modules provided: null
[INFO] [amd] search result for projectY/app/src/androidTest/java/com/example/instrumentationTest/filters/TestSegmentation.kt resulted in null
[INFO] [amd] Couldn't find containing project for file projectY/app/src/androidTest/java/com/example/instrumentationTest/filters/TestSegmentation.kt. Adding to unknownFiles.
...
[INFO] [amd] unknownFiles: [projectY/app/src/androidTest/java/com/example/instrumentationTest/filters/TestSegmentation.kt], changedProjects: [], buildAll: false
[INFO] [amd] checking whether I should include : and my answer is false
...

When running ./gradlew assembleAffectedAndroidTests -Paffected_module_detector.enable it will display similiar text, but with some changes:


[INFO] [amd] Using real detector with ALL_AFFECTED_PROJECTS
[INFO] [amd] Modules provided: null
[INFO] [amd] search result for projectY/app/src/androidTest/java/com/example/instrumentationTest/filters/TestSegmentation.kt resulted in null
[INFO] [amd] Couldn't find containing project for file projectY/app/src/androidTest/java/com/example/instrumentationTest/filters/TestSegmentation.kt. Adding to unknownFiles.
...
[INFO] [amd] unknownFiles: [projectY/app/src/androidTest/java/com/example/instrumentationTest/filters/TestSegmentation.kt], changedProjects: [], buildAll: false
[INFO] [amd] checking whether I should include :app and my answer is false
[INFO] [amd] checking whether I should include :core and my answer is false
....

Seems like AMD is unable to map the changed file to a Gradle module, but It sees that a file has changed, but It cannot find a corresponding Gradle project for that file. Therefore, it cannot flag any module as "affected".

How it can be fixed ?

Additional gradle information:

Gradle project has next structure:

------------------------------------------------------------
Root project 'projectY'
------------------------------------------------------------
Root project 'projectY'
+--- Project ':app'
+--- Project ':core'
...

In settings.gradle modules are applied from gradle file
apply from: 'module-includes.gradle'

File module-includes contains gradle files


include ":app"
include ":core"
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions