|
1 | 1 | package pl.allegro.tech.build.axion.release.domain
|
2 | 2 |
|
3 | 3 | import org.gradle.api.Project
|
| 4 | +import org.gradle.api.artifacts.Configuration |
4 | 5 | import org.gradle.api.artifacts.Dependency
|
5 | 6 | import org.gradle.api.artifacts.DependencyConstraint
|
6 | 7 |
|
7 | 8 | class SnapshotDependenciesChecker {
|
8 | 9 |
|
9 | 10 | Collection<String> snapshotVersions(Project project) {
|
10 |
| - Collection<String> projectVersions = project.rootProject.allprojects.collect {toFullVersion(it)} |
11 |
| - Collection<String> allDependenciesVersions = project.allprojects.collect { |
12 |
| - it.configurations.collect { config -> |
13 |
| - config.allDependencies.findAll {isSnapshot(it)}.collect {toFullVersion(it)}+ |
14 |
| - config.allDependencyConstraints.findAll {isSnapshot(it)}.collect {toFullVersion(it)} |
15 |
| - |
16 |
| - } |
17 |
| - }.flatten().unique() |
| 11 | + Collection<String> projectVersions = project.getRootProject().getAllprojects() |
| 12 | + .collect { toFullVersion(it) } |
| 13 | + Collection<Configuration> configurations = project.getRootProject().getAllprojects() |
| 14 | + .collect { it.getConfigurations() }.flatten() as Collection<Configuration> |
| 15 | + Collection<String> allDependenciesVersions = new HashSet<>() |
| 16 | + for (Configuration config : configurations) { |
| 17 | + Collection<String> versions = config.getAllDependencies() |
| 18 | + .findAll { isSnapshot(it) } |
| 19 | + .collect { toFullVersion(it) } |
| 20 | + +config.getAllDependencyConstraints() |
| 21 | + .findAll { isSnapshot(it) } |
| 22 | + .collect { toFullVersion(it) } |
| 23 | + allDependenciesVersions.addAll(versions) |
| 24 | + } |
18 | 25 | allDependenciesVersions.removeAll(projectVersions)
|
19 | 26 | return allDependenciesVersions
|
20 | 27 | }
|
21 | 28 |
|
22 | 29 | boolean isSnapshot(Dependency dependency) {
|
23 | 30 | dependency.version?.endsWith("-SNAPSHOT")
|
24 | 31 | }
|
| 32 | + |
25 | 33 | boolean isSnapshot(DependencyConstraint dependency) {
|
26 | 34 | dependency.version?.endsWith("-SNAPSHOT")
|
27 | 35 | }
|
|
0 commit comments