Skip to content

Commit

Permalink
Fix ConcurrentModificationException in SnapshotDependenciesChecker (#819
Browse files Browse the repository at this point in the history
)

* Fix ConcurrentModificationException

* Fix ConcurrentModificationException

---------

Co-authored-by: saukhmv <saukhmv@nspk.ru>
  • Loading branch information
imvs and saukhmv authored Sep 23, 2024
1 parent 428ee60 commit 0e15a62
Showing 1 changed file with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
package pl.allegro.tech.build.axion.release.domain

import org.gradle.api.Project
import org.gradle.api.artifacts.Configuration
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()
Collection<String> projectVersions = project.getRootProject().getAllprojects()
.collect { toFullVersion(it) }
Collection<Configuration> configurations = project.getRootProject().getAllprojects()
.collect { it.getConfigurations() }.flatten() as Collection<Configuration>
Collection<String> allDependenciesVersions = new HashSet<>()
for (Configuration config : configurations) {
Collection<String> versions = config.getAllDependencies()
.findAll { isSnapshot(it) }
.collect { toFullVersion(it) }
+config.getAllDependencyConstraints()
.findAll { isSnapshot(it) }
.collect { toFullVersion(it) }
allDependenciesVersions.addAll(versions)
}
allDependenciesVersions.removeAll(projectVersions)
return allDependenciesVersions
}

boolean isSnapshot(Dependency dependency) {
dependency.version?.endsWith("-SNAPSHOT")
}

boolean isSnapshot(DependencyConstraint dependency) {
dependency.version?.endsWith("-SNAPSHOT")
}
Expand Down

0 comments on commit 0e15a62

Please sign in to comment.