forked from ben-manes/gradle-versions-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement ben-manes#325 rejectVersionIf
- Loading branch information
Jean-Michel Fayard
committed
Sep 9, 2019
1 parent
f8d60b3
commit 092837a
Showing
4 changed files
with
150 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...ovy/com/github/benmanes/gradle/versions/updates/resolutionstrategy/ComponentFilter.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.github.benmanes.gradle.versions.updates.resolutionstrategy | ||
|
||
interface ComponentFilter { | ||
|
||
boolean reject(ComponentSelectionWithCurrent candidate) | ||
|
||
} |
45 changes: 40 additions & 5 deletions
45
.../benmanes/gradle/versions/updates/resolutionstrategy/ComponentSelectionWithCurrent.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,48 @@ | ||
package com.github.benmanes.gradle.versions.updates.resolutionstrategy | ||
|
||
import groovy.transform.TupleConstructor | ||
import com.thoughtworks.xstream.mapper.Mapper | ||
import org.gradle.api.artifacts.ComponentMetadata | ||
import org.gradle.api.artifacts.ComponentSelection | ||
import org.gradle.api.artifacts.component.ModuleComponentIdentifier | ||
|
||
@TupleConstructor(includeFields=true) | ||
class ComponentSelectionWithCurrent { | ||
import javax.annotation.Nullable | ||
|
||
final String currentVersion | ||
class ComponentSelectionWithCurrent implements ComponentSelection { | ||
|
||
ComponentSelectionWithCurrent(String currentVersion, ComponentSelection delegate) { | ||
this.currentVersion = currentVersion | ||
this.delegate = delegate | ||
} | ||
|
||
@Delegate | ||
final String currentVersion | ||
private final ComponentSelection delegate | ||
|
||
ModuleComponentIdentifier getCandidate() { | ||
return delegate.candidate | ||
} | ||
|
||
@Nullable | ||
ComponentMetadata getMetadata() { | ||
return delegate.metadata | ||
} | ||
|
||
def <T> T getDescriptor(Class<T> descriptorClass) { | ||
return delegate.getDescriptor(descriptorClass) | ||
} | ||
|
||
void reject(String reason) { | ||
delegate.reject(reason) | ||
} | ||
|
||
|
||
@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(); | ||
} | ||
} |