All Downloads are FREE. Search and download functionalities are using the official Maven repository.

pl.allegro.tech.build.axion.release.domain.SnapshotDependenciesChecker.groovy Maven / Gradle / Ivy

There is a newer version: 1.18.15
Show newest version
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 snapshotVersions(Project project) {
        Collection projectVersions = project.allprojects.collect {toFullVersion(it)}
        Collection 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()
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy