From a8874167f663885f2d3371801cf03681576ac817 Mon Sep 17 00:00:00 2001 From: Guillaume Jacquart Date: Tue, 2 May 2023 21:25:17 +0200 Subject: 1200: rename everything to AdvancedPrivacy --- .../advancedprivacy/buildsrc/DependencyUpdates.kt | 42 ++++++++++++++++++++++ .../e/privacycentral/buildsrc/DependencyUpdates.kt | 42 ---------------------- 2 files changed, 42 insertions(+), 42 deletions(-) create mode 100644 buildSrc/src/main/java/foundation/e/advancedprivacy/buildsrc/DependencyUpdates.kt delete mode 100644 buildSrc/src/main/java/foundation/e/privacycentral/buildsrc/DependencyUpdates.kt (limited to 'buildSrc/src/main/java/foundation/e') diff --git a/buildSrc/src/main/java/foundation/e/advancedprivacy/buildsrc/DependencyUpdates.kt b/buildSrc/src/main/java/foundation/e/advancedprivacy/buildsrc/DependencyUpdates.kt new file mode 100644 index 0000000..1f233d5 --- /dev/null +++ b/buildSrc/src/main/java/foundation/e/advancedprivacy/buildsrc/DependencyUpdates.kt @@ -0,0 +1,42 @@ +package foundation.e.advancedprivacy.buildsrc + +enum class ReleaseType(private val level: Int) { + SNAPSHOT(0), + DEV(1), + ALPHA(10), + BETA(20), + RC(60), + RELEASE(100); + + fun isEqualOrMoreStableThan(other: ReleaseType): Boolean = level >= other.level + + fun isLessStableThan(other: ReleaseType): Boolean = level < other.level +} + +object DependencyUpdates { + private val stableKeywords = arrayOf("RELEASE", "FINAL", "GA") + private val releaseRegex = "^[0-9,.v-]+(-r)?$".toRegex(RegexOption.IGNORE_CASE) + private val rcRegex = releaseKeywordRegex("rc") + private val betaRegex = releaseKeywordRegex("beta") + private val alphaRegex = releaseKeywordRegex("alpha") + private val devRegex = releaseKeywordRegex("dev") + + @JvmStatic + fun versionToRelease(version: String): ReleaseType { + val stableKeyword = stableKeywords.any { version.toUpperCase().contains(it) } + if (stableKeyword) return ReleaseType.RELEASE + + return when { + releaseRegex.matches(version) -> ReleaseType.RELEASE + rcRegex.matches(version) -> ReleaseType.RC + betaRegex.matches(version) -> ReleaseType.BETA + alphaRegex.matches(version) -> ReleaseType.ALPHA + devRegex.matches(version) -> ReleaseType.DEV + else -> ReleaseType.SNAPSHOT + } + } + + private fun releaseKeywordRegex(keyword: String): Regex { + return "^[0-9,.v-]+(-$keyword[0-9]*)$".toRegex(RegexOption.IGNORE_CASE) + } +} \ No newline at end of file diff --git a/buildSrc/src/main/java/foundation/e/privacycentral/buildsrc/DependencyUpdates.kt b/buildSrc/src/main/java/foundation/e/privacycentral/buildsrc/DependencyUpdates.kt deleted file mode 100644 index 852c55c..0000000 --- a/buildSrc/src/main/java/foundation/e/privacycentral/buildsrc/DependencyUpdates.kt +++ /dev/null @@ -1,42 +0,0 @@ -package foundation.e.privacycentral.buildsrc - -enum class ReleaseType(private val level: Int) { - SNAPSHOT(0), - DEV(1), - ALPHA(10), - BETA(20), - RC(60), - RELEASE(100); - - fun isEqualOrMoreStableThan(other: ReleaseType): Boolean = level >= other.level - - fun isLessStableThan(other: ReleaseType): Boolean = level < other.level -} - -object DependencyUpdates { - private val stableKeywords = arrayOf("RELEASE", "FINAL", "GA") - private val releaseRegex = "^[0-9,.v-]+(-r)?$".toRegex(RegexOption.IGNORE_CASE) - private val rcRegex = releaseKeywordRegex("rc") - private val betaRegex = releaseKeywordRegex("beta") - private val alphaRegex = releaseKeywordRegex("alpha") - private val devRegex = releaseKeywordRegex("dev") - - @JvmStatic - fun versionToRelease(version: String): ReleaseType { - val stableKeyword = stableKeywords.any { version.toUpperCase().contains(it) } - if (stableKeyword) return ReleaseType.RELEASE - - return when { - releaseRegex.matches(version) -> ReleaseType.RELEASE - rcRegex.matches(version) -> ReleaseType.RC - betaRegex.matches(version) -> ReleaseType.BETA - alphaRegex.matches(version) -> ReleaseType.ALPHA - devRegex.matches(version) -> ReleaseType.DEV - else -> ReleaseType.SNAPSHOT - } - } - - private fun releaseKeywordRegex(keyword: String): Regex { - return "^[0-9,.v-]+(-$keyword[0-9]*)$".toRegex(RegexOption.IGNORE_CASE) - } -} \ No newline at end of file -- cgit v1.2.1