Skip to content

Commit 0e15a62

Browse files
imvssaukhmv
and
saukhmv
authored
Fix ConcurrentModificationException in SnapshotDependenciesChecker (#819)
* Fix ConcurrentModificationException * Fix ConcurrentModificationException --------- Co-authored-by: saukhmv <saukhmv@nspk.ru>
1 parent 428ee60 commit 0e15a62

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

src/main/groovy/pl/allegro/tech/build/axion/release/domain/SnapshotDependenciesChecker.groovy

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,35 @@
11
package pl.allegro.tech.build.axion.release.domain
22

33
import org.gradle.api.Project
4+
import org.gradle.api.artifacts.Configuration
45
import org.gradle.api.artifacts.Dependency
56
import org.gradle.api.artifacts.DependencyConstraint
67

78
class SnapshotDependenciesChecker {
89

910
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+
}
1825
allDependenciesVersions.removeAll(projectVersions)
1926
return allDependenciesVersions
2027
}
2128

2229
boolean isSnapshot(Dependency dependency) {
2330
dependency.version?.endsWith("-SNAPSHOT")
2431
}
32+
2533
boolean isSnapshot(DependencyConstraint dependency) {
2634
dependency.version?.endsWith("-SNAPSHOT")
2735
}

0 commit comments

Comments
 (0)