From 3add857ecdc8791ae979ce363de2feed816e0bd3 Mon Sep 17 00:00:00 2001 From: Ben Manes Date: Tue, 15 Oct 2019 21:25:57 -0700 Subject: [PATCH] Remove unnecessary escapes in regex (fixes #354) --- README.md | 12 ++++++------ examples/groovy/build.gradle | 2 +- examples/kotlin/build.gradle.kts | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 9eedc51e..73157570 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ The strategy can be specified either on the task or as a system property for ad ```groovy gradle dependencyUpdates -Drevision=release ``` - + To further define which version to accept, you need to define what means an unstable version. Sadly, there are no agreed standard on this, but this is a good starting point: @@ -96,7 +96,7 @@ no agreed standard on this, but this is a good starting point: ```groovy def isNonStable = { String version -> def stableKeyword = ['RELEASE', 'FINAL', 'GA'].any { it -> version.toUpperCase().contains(it) } - def regex = /^[0-9,\\.v\\-]+(-r)?$/ + def regex = /^[0-9,.v-]+(-r)?$/ return !stableKeyword && !(version ==~ regex) } ``` @@ -108,7 +108,7 @@ def isNonStable = { String version -> ```kotlin fun isNonStable(version: String): Boolean { val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.toUpperCase().contains(it) } - val regex = "^[0-9,\\.v\\-]+(-r)?$".toRegex() + val regex = "^[0-9,.v-]+(-r)?$".toRegex() val isStable = stableKeyword || regex.matches(version) return isStable.not() } @@ -188,8 +188,8 @@ tasks.withType { #### Constraints -If you use constraints, for example to define a BOM using the [`java-platform`](https://docs.gradle.org/current/userguide/java_platform_plugin.html) -plugin or to [manage](https://docs.gradle.org/current/userguide/managing_transitive_dependencies.html#sec:dependency_constraints) +If you use constraints, for example to define a BOM using the [`java-platform`](https://docs.gradle.org/current/userguide/java_platform_plugin.html) +plugin or to [manage](https://docs.gradle.org/current/userguide/managing_transitive_dependencies.html#sec:dependency_constraints) transitive dependency versions, you can enable checking of constraints by specifying the `checkConstraints` attribute of the `dependencyUpdates` task. @@ -226,7 +226,7 @@ Have a look at [`examples/groovy`](https://github.com/ben-manes/gradle-versions- ```bash # Publish the latest version of the plugin to mavenLocal() -$ ./gradlew install +$ ./gradlew install # Try out the samples $ ./gradlew -p examples/groovy dependencyUpdate diff --git a/examples/groovy/build.gradle b/examples/groovy/build.gradle index 8f580fd1..b5c3976a 100644 --- a/examples/groovy/build.gradle +++ b/examples/groovy/build.gradle @@ -32,7 +32,7 @@ configurations { def isNonStable = { String version -> def stableKeyword = ['RELEASE', 'FINAL', 'GA'].any { it -> version.toUpperCase().contains(it) } - def regex = /^[0-9,\\.v\\-]+(-r)?$/ + def regex = /^[0-9,.v-]+(-r)?$/ return !stableKeyword && !(version ==~ regex) } diff --git a/examples/kotlin/build.gradle.kts b/examples/kotlin/build.gradle.kts index cd2050b7..6415f91a 100644 --- a/examples/kotlin/build.gradle.kts +++ b/examples/kotlin/build.gradle.kts @@ -22,7 +22,7 @@ configurations { fun isNonStable(version: String): Boolean { val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.toUpperCase().contains(it) } - val regex = "^[0-9,\\.v\\-]+(-r)?$".toRegex() + val regex = "^[0-9,.v-]+(-r)?$".toRegex() val isStable = stableKeyword || regex.matches(version) return isStable.not() }