-
Notifications
You must be signed in to change notification settings - Fork 149
/
SnapshotDependenciesChecker.groovy
32 lines (26 loc) · 1.15 KB
/
SnapshotDependenciesChecker.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package pl.allegro.tech.build.axion.release.domain
import org.gradle.api.Project
import org.gradle.api.artifacts.Dependency
import org.gradle.api.artifacts.DependencyConstraint
class SnapshotDependenciesChecker {
Collection<String> snapshotVersions(Project project) {
Collection<String> projectVersions = project.rootProject.allprojects.collect {toFullVersion(it)}
Collection<String> allDependenciesVersions = project.allprojects.collect {
it.configurations.collect { config ->
config.allDependencies.findAll {isSnapshot(it)}.collect {toFullVersion(it)}+
config.allDependencyConstraints.findAll {isSnapshot(it)}.collect {toFullVersion(it)}
}
}.flatten().unique()
allDependenciesVersions.removeAll(projectVersions)
return allDependenciesVersions
}
boolean isSnapshot(Dependency dependency) {
dependency.version?.endsWith("-SNAPSHOT")
}
boolean isSnapshot(DependencyConstraint dependency) {
dependency.version?.endsWith("-SNAPSHOT")
}
String toFullVersion(it) {
"${it.group}:${it.name}:${it.version}".toString()
}
}