question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Consider to lift off root project requirement

See original GitHub issue

Thank you for your effort. I would like to initiate a discussion and share a snippet I find useful.

By default ben-manes plugin sets a listener to copy every dependency at every configuration at every submodule with + version. Due to the limitation of Gradle resolving configuration can not be done in parallel. In a typical android kotlin project, google and jetbrains plugins set dozens of configurations per module. Multiplied by 10th of modules this becomes extremely slow to execute. And also pointless waste of resources as the same dependency would be resolved hundreds of times over and over again.

For example, on a project I’m working on with 350 dependencies declared at libs.versions.toml running dependencyUpdates from root takes over 50 minutes to execute.

As an optimization technic, I’ve found that creating a single configuration and looping through every dependency gives the same new-updates result in under a minute.

Creating an artificial module, called dependency-updates-report with the next content:

// dependency-updates-report/build.gradle
plugins {
    id 'com.github.ben-manes.versions'
}

configurations {
    dependencyUpdateConfiguration
}

dependencies {
    def versionCatalog = project.extensions.getByType(VersionCatalogsExtension).named("libs")
    versionCatalog.dependencyAliases.each {
        versionCatalog.findDependency(it).ifPresent {
            dependencyUpdateConfiguration(it)
        }
    }
}

tasks.named("dependencyUpdates").configure {
    resolutionStrategy {
        componentSelection { rules ->
            rules.all { ComponentSelection selection ->
                boolean rejected = ['alpha', 'beta', 'rc', 'm', 'eap'].any { qualifier ->
                    selection.candidate.version.toLowerCase().contains(qualifier)
                }
                if (rejected) {
                    selection.reject('Alpha, beta, release candidate, milestone and early access preview versions are rejected from report')
                }
            }
        }
    }
}

And running the same ./gradlew dependencyUpdates task will now return updates report times faster.

I believe you would lose the “find unused dependencies” functionality with this approach. This is why I want to initiate discussion, as I’m not sure how useful you consider that to be. I think that tools like https://github.com/autonomousapps/dependency-analysis-android-gradle-plugin could be more effective at findings as it actually checks usage in code, not just declaration at build.gradle files.

Thanks again this plugin has been published at the perfect timing for me as I’m investigating switch to versions catalog.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
hvissercommented, Nov 4, 2021

Thanks for testing that! I think that for now that means there’s no action required to adjust the plugin, so I’ll close the issue. Feel free to reopen if you think that makes sense.

1reaction
plastivcommented, Nov 4, 2021

I have made an experiment and yes, an applied ben-manes plugin to every submodule runs fast enough 👍 TIL

Read more comments on GitHub >

github_iconTop Results From Across the Web

Complete Guide To Requirements Gathering Process + ...
Here are the steps on how to gather requirements, taking you through a complete requirements gathering process. These steps will help you to ......
Read more >
7 common project risks and how to prevent them
Learn about the most common project risks so your team can analyze them during the project planning phase, prevent conflict, and prepare for ......
Read more >
Gradle Lifecycle Evaluation Order For Multi-Project Builds
Time to lift off the covers and see what's really happening with our multi-project builds. First though, as a reminder, remember that the ......
Read more >
Requirements vs. specifications and other comparisons
This question and answer column examines requirements and specification, quality checks for a work breakdown structure (WBS), the project sponsor role, ...
Read more >
Demystifying the 5 Phases of Project Management
It is up to PMPs to apply the techniques and phases covered in the PMBOK ® Guide to the unique requirements of their...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found