Search in sources :

Example 1 with CompositeVersionSelector

use of org.gradle.api.internal.artifacts.ivyservice.ivyresolve.strategy.CompositeVersionSelector in project gradle by gradle.

the class RejectedModuleMessageBuilder method renderVersionConstraint.

private static String renderVersionConstraint(ResolvedVersionConstraint constraint) {
    if (isRejectAll(constraint)) {
        return "rejects all versions";
    }
    VersionSelector preferredSelector = constraint.getPreferredSelector();
    VersionSelector rejectedSelector = constraint.getRejectedSelector();
    StringBuilder sb = new StringBuilder("prefers ");
    sb.append('\'');
    sb.append(preferredSelector.getSelector());
    sb.append('\'');
    if (rejectedSelector != null) {
        sb.append(", rejects ");
        if (rejectedSelector instanceof CompositeVersionSelector) {
            sb.append("any of \"");
            int i = 0;
            for (VersionSelector selector : ((CompositeVersionSelector) rejectedSelector).getSelectors()) {
                if (i++ > 0) {
                    sb.append(", ");
                }
                sb.append('\'');
                sb.append(selector.getSelector());
                sb.append('\'');
            }
            sb.append("\"");
        } else {
            sb.append('\'');
            sb.append(rejectedSelector.getSelector());
            sb.append('\'');
        }
    }
    return sb.toString();
}
Also used : CompositeVersionSelector(org.gradle.api.internal.artifacts.ivyservice.ivyresolve.strategy.CompositeVersionSelector) CompositeVersionSelector(org.gradle.api.internal.artifacts.ivyservice.ivyresolve.strategy.CompositeVersionSelector) VersionSelector(org.gradle.api.internal.artifacts.ivyservice.ivyresolve.strategy.VersionSelector) ResolvedVersionConstraint(org.gradle.api.internal.artifacts.ResolvedVersionConstraint)

Aggregations

ResolvedVersionConstraint (org.gradle.api.internal.artifacts.ResolvedVersionConstraint)1 CompositeVersionSelector (org.gradle.api.internal.artifacts.ivyservice.ivyresolve.strategy.CompositeVersionSelector)1 VersionSelector (org.gradle.api.internal.artifacts.ivyservice.ivyresolve.strategy.VersionSelector)1