Skip to content

Commit

Permalink
PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Michel Fayard committed Sep 9, 2019
1 parent 9d473dc commit 182d28e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ no agreed standard on this, but this is a good starting point:
def isNonStable = { String version ->
def stableKeyword = ['RELEASE', 'FINAL', 'GA'].any { it -> version.toUpperCase().contains(it) }
def regex = /^[0-9,.v-]+$/
return !stableKeyword && !(version ==~ /^[0-9,.v-]+$/)
return !stableKeyword && !(version ==~ regex)
}
```

Expand Down Expand Up @@ -139,7 +139,7 @@ dependencyUpdates {
// Example 3: using the full syntax
resolutionStrategy {
componentSelection { rules ->
rules.all { ComponentSelection selection ->
rules.all {
if (isNonStable(candidate.version) && !isNonStable(currentVersion)) {
selection.reject('Release candidate')
}
Expand Down
13 changes: 12 additions & 1 deletion examples/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-]+$/
return !stableKeyword && !(version ==~ /^[0-9,.v-]+$/)
return !stableKeyword && !(version ==~ regex)
}

dependencyUpdates {
Expand All @@ -41,6 +41,17 @@ dependencyUpdates {
rejectVersionIf { selection ->
isNonStable(selection.candidate.version) && !isNonStable(selection.currentVersion)
}

// resolutionStrategy {
// componentSelection { rules ->
// rules.all {
// if (isNonStable(candidate.version) && !isNonStable(currentVersion)) {
// selection.reject('Release candidate')
// }
// }
// }
// }

}

dependencies {
Expand Down
10 changes: 10 additions & 0 deletions examples/kotlin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ tasks.withType<DependencyUpdatesTask> {
isNonStable(selection.candidate.version) && isNonStable(selection.currentVersion).not()
}

resolutionStrategy {
componentSelection {
all {
if (isNonStable(candidate.version) && !isNonStable(currentVersion)) {
reject("Release candidate")
}
}
}
}

// optional parameters
checkForGradleUpdate = true
outputFormatter = "json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ class ComponentSelectionWithCurrent implements ComponentSelection {

@Override
public String toString() {
final StringBuffer sb = new StringBuffer("ComponentSelectionWithCurrent{");
sb.append("group=").append(getCandidate().group);
sb.append(", module=").append(getCandidate().module);
sb.append(", version=").append(getCandidate().version)
sb.append(", currentVersion='").append(currentVersion).append('\'');
sb.append('}');
return sb.toString();
return """\
ComponentSelectionWithCurrent{
group="${candidate.group}",
module="${candidate.module}",
version="${candidate.version}",
currentVersion="$currentVersion",
}"""
}
}

0 comments on commit 182d28e

Please sign in to comment.