Skip to content

Instantly share code, notes, and snippets.

@JakeWharton
Last active February 7, 2023 10:49
Show Gist options
  • Save JakeWharton/2066f5e4f08fbaaa68fd to your computer and use it in GitHub Desktop.
Save JakeWharton/2066f5e4f08fbaaa68fd to your computer and use it in GitHub Desktop.
Prevent wildcard versions in your Gradle project. These undermine deterministic and hermetic builds and are generally considered bad practice.
allprojects {
afterEvaluate { project ->
project.configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.version.contains('+')) {
throw new GradleException("Wildcard dependency forbidden: ${requested.group}:${requested.name}:${requested.version}")
}
}
}
}
}
@JakeWharton
Copy link
Author

@plastiv Good point.

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