Skip to content

Instantly share code, notes, and snippets.

@nerro
Last active October 27, 2023 10:20
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nerro/41cd6f8273a05b3da7cad1f2e9caf1c7 to your computer and use it in GitHub Desktop.
Save nerro/41cd6f8273a05b3da7cad1f2e9caf1c7 to your computer and use it in GitHub Desktop.
Gradle: task 'resolveDependencies' for CI
task resolveDependencies {
setDescription "Resolves all projects dependencies from the repository."
setGroup "Build Server"
doLast {
rootProject.allprojects { project ->
project.buildscript.configurations.forEach { configuration ->
if (configuration.canBeResolved) {
configuration.resolve()
}
}
project.configurations.forEach { configuration ->
if (configuration.canBeResolved) {
configuration.resolve()
}
}
}
}
}
@slamdev
Copy link

slamdev commented Feb 2, 2020

nice task, helped me a lot! small refactoring:

    doLast {
        rootProject.allprojects { project ->
            Set<Configuration> configurations = project.buildscript.configurations + project.configurations
            configurations.findAll { c -> c.canBeResolved }
                    .forEach { c -> c.resolve() }
        }
    }

@farukg
Copy link

farukg commented Aug 6, 2020

thx, very useful!
Helped me with a docker build issue throwing randomly SSL shut down incorrectly errors and also caching downloads of course

@shilazi
Copy link

shilazi commented Oct 27, 2023

thx, code with kotlin

build.gradle.kts

task("resolveDependencies") {
    description = "Resolves all projects dependencies from the repository."
    group = "Build Server"

    doLast {
        rootProject.allprojects {
            (project.buildscript.configurations + project.configurations).forEach { configuration ->
                if (configuration.isCanBeResolved) {
                    configuration.resolve()
                }
            }
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment