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

How to avoid using dependencyAnalysys lambda in each build.gradle file #1342

Open
9tilov opened this issue Dec 15, 2024 · 1 comment
Open
Labels
question Further information is requested

Comments

@9tilov
Copy link

9tilov commented Dec 15, 2024

I'm actively using this plugin and we have move than 1k modules in the project. Each module has its own whitelisted dependencies which I have to add to dependencyAnalysis -> exclude block. It would be nice to have one whitelist file with all modules and all excludes and avoid using this dependencyAnalysis block in each module. What are recommendations here?
Example of current usage:

module1: build.gradle.kts

dependencyAnalysis {
    val fail = "fail"
    val ignore = "ignore"
    issues {
        onUnusedDependencies {
            severity(fail)
            exclude(
                ":somemodule1:deps1",
                libs.dagger.android.support.map { it.name() }.get(),
                "",
            )
        }
        onUsedTransitiveDependencies { severity(ignore) }
        onIncorrectConfiguration { severity(ignore) }
        onCompileOnly { severity(ignore) }
        onRuntimeOnly { severity(ignore) }
        onUnusedAnnotationProcessors { severity(ignore) }
        onRedundantPlugins { severity(ignore) }
    }
}

Nice to have:

unused-deps-whitelist.txt

module1 {
    ":somemodule1:deps1",
    libs.dagger.android.support.map { it.name() }.get(),
},
module2 {
    ":somemodule2:deps2",
    libs.dagger.android.support.map { it.name() }.get(),
}
@autonomousapps
Copy link
Owner

You can do this all from the root script! See https://github.com/autonomousapps/dependency-analysis-gradle-plugin/wiki/Customizing-plugin-behavior#failure-conditions-and-filtering. Would look like this:

// root build script
dependencyAnalysis {
  issues {
    // "all" runs against EVERY module
    all {
      onUnusedDependencies { ... }
      ...
    }

    // "project" runs against just the specified project
    project(':lib') {
      onUnusedDependencies { ... }
      ...
    }
  }
}

and you can do that for each module separately if you need to. Note that global behavior can be defined in all{}, and anything more specific will take precedence over the global behavior.

@autonomousapps autonomousapps added the question Further information is requested label Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants