summaryrefslogtreecommitdiff
path: root/build-plugin/src/main/kotlin/thunderbird.dependency.check.gradle.kts
blob: 69eb656d052b8f1c2f74a06fcbdc06136f5863aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask

plugins {
    id("com.github.ben-manes.versions")
}

tasks.withType<DependencyUpdatesTask> {
    rejectVersionIf {
        isNonStable(candidate.version) && !isNonStable(currentVersion)
    }
}

fun isNonStable(version: String): Boolean {
    val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.toUpperCase().contains(it) }
    val regex = "^[\\d,.v-]+(-r)?$".toRegex()
    val isStable = stableKeyword || regex.matches(version)
    return isStable.not()
}