Skip to content

Commit

Permalink
Remove unnecessary escapes in regex (fixes #354)
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-manes committed Oct 16, 2019
1 parent 7dba9c4 commit 3add857
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
}
```
Expand All @@ -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()
}
Expand Down Expand Up @@ -188,8 +188,8 @@ tasks.withType<DependencyUpdatesTask> {

#### 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.

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/groovy/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion examples/kotlin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down

0 comments on commit 3add857

Please sign in to comment.