org.basepom.mojo.dvc.version.VersionResolutionElement Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dependency-versions-check-maven-plugin Show documentation
Show all versions of dependency-versions-check-maven-plugin Show documentation
The dependency-versions-check plugin verifies that all resolved
versions of artifacts are at least the versions specified by
the project dependencies.
The Maven dependency resolution process will substitute versions for
the different artifacts in a dependency tree and sometimes chooses incompatible
versions which leads to difficult to detect problems.
This plugin resolves all dependencies and collects any requested version. It evaluates
whether the resolved versions are compatible to the requested versions and reports possible
conflicts.
The newest version!
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.basepom.mojo.dvc.version;
import org.basepom.mojo.dvc.QualifiedName;
import java.util.Objects;
import com.google.common.base.MoreObjects;
public final class VersionResolutionElement
implements Comparable {
/**
* Requesting Dependency name.
*/
private final QualifiedName requestingDependency;
/**
* True if the dependency was managed to this version.
*/
private final boolean managedDependency;
/**
* True if this version resolution is directly from the root project.
*/
private final boolean directDependency;
private boolean conflict = false;
VersionResolutionElement(final QualifiedName requestingDependency, final boolean managedDependency, final boolean directDependency) {
this.requestingDependency = requestingDependency;
this.managedDependency = managedDependency;
this.directDependency = directDependency;
}
public QualifiedName getRequestingDependency() {
return requestingDependency;
}
public boolean isManagedDependency() {
return managedDependency;
}
public boolean isDirectDependency() {
return directDependency;
}
public void conflict() {
this.conflict = true;
}
public boolean hasConflict() {
return conflict;
}
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final VersionResolutionElement that = (VersionResolutionElement) o;
return managedDependency == that.managedDependency
&& directDependency == that.directDependency
&& requestingDependency.equals(that.requestingDependency);
}
@Override
public int hashCode() {
return Objects.hash(requestingDependency, managedDependency, directDependency);
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("requestingDependency", requestingDependency)
.add("managedDependency", managedDependency)
.add("directDependency", directDependency)
.add("conflict", conflict)
.toString();
}
@Override
public int compareTo(final VersionResolutionElement other) {
if (other == null) {
return 1;
} else if (other == this || equals(other)) {
return 0;
} else {
return getRequestingDependency().getMinimalName().compareTo(other.getRequestingDependency().getMinimalName());
}
}
}